Exception chaining
See original GitHub issueI would like to be able to have sentry display the original exception in the chain. In a lot of places we do something like this:
try:
v = {}['a']
except KeyError as e:
raise ValueError('failed') from e
I would like to be able to get at the KeyError in sentry just like the output of python when this code is ran:
Traceback (most recent call last):
File "t.py", line 2, in <module>
v = {}['a']
KeyError: 'a'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "t.py", line 4, in <module>
raise ValueError('failed') from e
ValueError: failed
Is this possible in raven?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:25 (18 by maintainers)
Top Results From Across the Web
Chained Exceptions in Java - Baeldung
Chained Exception helps to identify a situation in which one exception causes another Exception in an application. For instance, consider a ...
Read more >Chained Exceptions - The Java™ Tutorials - Oracle Help Center
An application often responds to an exception by throwing another exception. In effect, the first exception causes the second exception. It can be...
Read more >Exception chaining - Wikipedia
Exception chaining, or exception wrapping, is an object-oriented programming technique of handling exceptions by re-throwing a caught exception after ...
Read more >Chained Exceptions in Java - GeeksforGeeks
Chained Exceptions allows to relate one exception with another exception, i.e one exception describes cause of another exception.
Read more >What is exception chaining in Java? - Educative.io
Exception chaining occurs when one exception causes another exception. The original exception is the cause of the second exception.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Would very much like this functionality!
I haven’t noticed any issues with Sentry’s aggregation of chained exceptions.
@phillbaker This is what you should be doing to take advantage of the client’s support for chaining:
That way Python chains the
ConnectionError
toMylibError
(and Sentry will render it), and Sentry will aggregate only on the info of what you pass toMylibError
’s constructor.Doing
raise MylibError("Unable to connect", e) from None
breaks this because (1) includingfrom None
breaks the chain (and so losing information from Sentry’s rendering), and (2) it includes theConnectionError
object in the constructor, which I could see causing Sentry not to aggregate differentMylibError
objects.