bugsnag / bugsnag-python

Official BugSnag error monitoring and error reporting for django, flask, tornado and other python apps.
https://docs.bugsnag.com/platforms/python/
MIT License
86 stars 42 forks source link

Improve stacktraces for handled errors #313

Closed imjoehaines closed 2 years ago

imjoehaines commented 2 years ago

Goal

Previously we used sys.exc_info for handled errors (unless the traceback option was provided), which may not be very useful — it shows where notify was called, not where the error was raised

Since Python 3, exception objects have a __traceback__ attribute that fixes this

Now we get the traceback in the following order of priority:

  1. the traceback option
  2. the exception.__traceback__ attribute
  3. sys.exc_info

We still need to read sys.exc_info for cases where a non-exception has been provided to notify — this isn't really a supported use-case but we do currently handle this