How to format traceback objects in Python

format_exc() is really just

etype, value, tb = sys.exc_info()
return ''.join(format_exception(etype, value, tb, limit))

So if you have the exception type, value, and traceback ready, it should be easy. If you have just the exception, notice that format_exception() is essentially:

a_list = ['Traceback (most recent call last):\n']
a_list = a_list + format_tb(tb, limit)

where limit defaults to None.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)