Avoid errors in cases where ``traceback`` is None
Merge pull request #1518 from astrofrog/fix-exception-handling

Avoid errors in cases where ``traceback`` is None