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(
637
637
mechanism = None , # type: Optional[Dict[str, Any]]
638
638
):
639
639
# type: (...) -> Dict[str, Any]
640
+ mechanism = mechanism or {"type" : "generic" , "handled" : True }
641
+
640
642
if exc_value is not None :
641
643
errno = get_errno (exc_value )
642
644
else :
643
645
errno = None
644
646
645
647
if errno is not None :
646
- mechanism = mechanism or {"type" : "generic" }
647
648
mechanism .setdefault ("meta" , {}).setdefault ("errno" , {}).setdefault (
648
649
"number" , errno
649
650
)
Original file line number Diff line number Diff line change @@ -140,6 +140,10 @@ def dogpark(environ, start_response):
140
140
assert error_event ["transaction" ] == "generic WSGI request"
141
141
assert error_event ["contexts" ]["trace" ]["op" ] == "http.server"
142
142
assert error_event ["exception" ]["values" ][0 ]["type" ] == "Exception"
143
+ assert error_event ["exception" ]["values" ][0 ]["mechanism" ] == {
144
+ "type" : "wsgi" ,
145
+ "handled" : False ,
146
+ }
143
147
assert (
144
148
error_event ["exception" ]["values" ][0 ]["value" ]
145
149
== "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):
91
91
assert Hub .current .last_event_id () == event_id
92
92
93
93
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
+
94
110
def test_option_before_send (sentry_init , capture_events ):
95
111
def before_send (event , hint ):
96
112
event ["extra" ] = {"before_send_called" : True }
You can’t perform that action at this time.
0 commit comments