File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 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):
110110 # type: (ExcInfo) -> None
111111 scope = sentry_sdk .get_current_scope ()
112112
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 )
116119
117- scope .root_span .set_status (SPANSTATUS .INTERNAL_ERROR )
118120 event , hint = event_from_exception (
119121 exc_info ,
120122 client_options = sentry_sdk .get_client ().options ,
@@ -135,8 +137,10 @@ def _sentry_execute(*args, **kwargs):
135137 exc_info = sys .exc_info ()
136138 _capture_exception (exc_info )
137139 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 )
140144
141145 return result
142146
Original file line number Diff line number Diff line change @@ -689,8 +689,7 @@ def fingerprint(self, value):
689689
690690 @property
691691 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]
694693 """Return the root span in the scope, if any."""
695694
696695 # there is no span/transaction on the scope
You can’t perform that action at this time.
0 commit comments