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