mirror of https://github.com/zulip/zulip.git
sentry: Ignore SystemExit and similar exceptions.
There are three exceptions in Python3 which are descended from BaseException, but not Exception: GeneratorExit, KeyboardInterrupt, and SystemExit. None of these are suitable to be sent to Sentry. For example, SystemExit is raised by `sys.exit`; in that sense, it is never "uncaught" because we chose to cause it explicitly. Use the suggested form[1] for ignoring specific classes of exceptions. [1] https://github.com/getsentry/sentry-python/issues/149#issuecomment-434448781
This commit is contained in:
parent
b5b7bc9a7c
commit
83645a3115
|
@ -12,7 +12,12 @@ from .config import PRODUCTION
|
|||
if TYPE_CHECKING:
|
||||
from sentry_sdk._types import Event, Hint
|
||||
|
||||
def add_context(event: 'Event', hint: 'Hint') -> 'Event':
|
||||
def add_context(event: 'Event', hint: 'Hint') -> Optional['Event']:
|
||||
if "exc_info" in hint:
|
||||
_, exc_value, _ = hint["exc_info"]
|
||||
# Ignore GeneratorExit, KeyboardInterrupt, and SystemExit exceptions
|
||||
if not isinstance(exc_value, Exception):
|
||||
return None
|
||||
from zerver.models import get_user_profile_by_id
|
||||
with capture_internal_exceptions():
|
||||
user_info = event.get("user", {})
|
||||
|
|
Loading…
Reference in New Issue