File tree 2 files changed +11
-8
lines changed
2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -111,11 +111,13 @@ def _capture_exception(exc_info):
111
111
# type: (ExcInfo) -> None
112
112
scope = sentry_sdk .get_current_scope ()
113
113
114
- if exc_info [0 ] in HUEY_CONTROL_FLOW_EXCEPTIONS :
115
- scope .root_span .set_status (SPANSTATUS .ABORTED )
116
- return
114
+ if scope .root_span is not None :
115
+ if exc_info [0 ] in HUEY_CONTROL_FLOW_EXCEPTIONS :
116
+ scope .root_span .set_status (SPANSTATUS .ABORTED )
117
+ return
118
+
119
+ scope .root_span .set_status (SPANSTATUS .INTERNAL_ERROR )
117
120
118
- scope .root_span .set_status (SPANSTATUS .INTERNAL_ERROR )
119
121
event , hint = event_from_exception (
120
122
exc_info ,
121
123
client_options = sentry_sdk .get_client ().options ,
@@ -136,8 +138,10 @@ def _sentry_execute(*args, **kwargs):
136
138
exc_info = sys .exc_info ()
137
139
_capture_exception (exc_info )
138
140
reraise (* exc_info )
139
- else :
140
- sentry_sdk .get_current_scope ().root_span .set_status (SPANSTATUS .OK )
141
+
142
+ root_span = sentry_sdk .get_current_scope ().root_span
143
+ if root_span is not None :
144
+ root_span .set_status (SPANSTATUS .OK )
141
145
142
146
return result
143
147
Original file line number Diff line number Diff line change @@ -692,8 +692,7 @@ def fingerprint(self, value):
692
692
693
693
@property
694
694
def root_span (self ):
695
- # type: () -> Any
696
- # would be type: () -> Optional[Span], see https://github.com/python/mypy/issues/3004
695
+ # type: () -> Optional[Span]
697
696
"""Return the root span in the scope, if any."""
698
697
699
698
# there is no span/transaction on the scope
You can’t perform that action at this time.
0 commit comments