File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -637,13 +637,14 @@ def single_exception_from_error_tuple(
637637 mechanism = None , # type: Optional[Dict[str, Any]]
638638):
639639 # type: (...) -> Dict[str, Any]
640+ mechanism = mechanism or {"type" : "generic" , "handled" : True }
641+
640642 if exc_value is not None :
641643 errno = get_errno (exc_value )
642644 else :
643645 errno = None
644646
645647 if errno is not None :
646- mechanism = mechanism or {"type" : "generic" }
647648 mechanism .setdefault ("meta" , {}).setdefault ("errno" , {}).setdefault (
648649 "number" , errno
649650 )
Original file line number Diff line number Diff line change @@ -140,6 +140,10 @@ def dogpark(environ, start_response):
140140 assert error_event ["transaction" ] == "generic WSGI request"
141141 assert error_event ["contexts" ]["trace" ]["op" ] == "http.server"
142142 assert error_event ["exception" ]["values" ][0 ]["type" ] == "Exception"
143+ assert error_event ["exception" ]["values" ][0 ]["mechanism" ] == {
144+ "type" : "wsgi" ,
145+ "handled" : False ,
146+ }
143147 assert (
144148 error_event ["exception" ]["values" ][0 ]["value" ]
145149 == "Fetch aborted. The ball was not returned."
Original file line number Diff line number Diff line change @@ -91,6 +91,22 @@ def test_event_id(sentry_init, capture_events):
9191 assert Hub .current .last_event_id () == event_id
9292
9393
94+ def test_generic_mechanism (sentry_init , capture_events ):
95+ sentry_init ()
96+ events = capture_events ()
97+
98+ try :
99+ raise ValueError ("aha!" )
100+ except Exception :
101+ capture_exception ()
102+
103+ (event ,) = events
104+ assert event ["exception" ]["values" ][0 ]["mechanism" ] == {
105+ "type" : "generic" ,
106+ "handled" : True ,
107+ }
108+
109+
94110def test_option_before_send (sentry_init , capture_events ):
95111 def before_send (event , hint ):
96112 event ["extra" ] = {"before_send_called" : True }
You can’t perform that action at this time.
0 commit comments