back to notes

python exceptions and logging

I always forget this syntax.

logging.error("barf", exc_info=True)

also,

exc_type, exc_value = sys.exc_info()[:2]

python2 docs warns not to save the traceback in a var due to garbage collection. fixed in later 2.7 point releases and python3.

python3 actually allows you to chain exceptions. you can say

myexception from anotherexception


last updated september 2016