Chadrick Blog

combine error message and tracestack into one string in python Exception

import traceback

def get\_full\_string\_of\_exception(e):
    tb = e.\_\_traceback\_\_
    tb\_lines = traceback.format\_tb(tb)
    tb\_str=""
    for line in tb\_lines:
        tb\_str += line + "\\n"

    full\_string = "{}\\n{}".format(str(e), tb\_str)

    return full\_string