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 @@ -111,11 +111,13 @@ def _capture_exception(exc_info):
111111 # type: (ExcInfo) -> None
112112 scope = sentry_sdk .get_current_scope ()
113113
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 )
117120
118- scope .root_span .set_status (SPANSTATUS .INTERNAL_ERROR )
119121 event , hint = event_from_exception (
120122 exc_info ,
121123 client_options = sentry_sdk .get_client ().options ,
@@ -136,8 +138,10 @@ def _sentry_execute(*args, **kwargs):
136138 exc_info = sys .exc_info ()
137139 _capture_exception (exc_info )
138140 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 )
141145
142146 return result
143147
Original file line number Diff line number Diff line change @@ -692,8 +692,7 @@ def fingerprint(self, value):
692692
693693 @property
694694 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]
697696 """Return the root span in the scope, if any."""
698697
699698 # there is no span/transaction on the scope
You can’t perform that action at this time.
0 commit comments