mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-05 22:53:57 +00:00
Merge commit 'b54299f28f74ed945f6b938190c31a03f64d5fe3' into main
This commit is contained in:
commit
3b648304ab
@ -14,7 +14,7 @@ from flask import g
|
|||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
from flask import make_response
|
from flask import make_response
|
||||||
from sentry_sdk import capture_exception
|
from sentry_sdk import capture_exception
|
||||||
from sentry_sdk import set_user
|
from sentry_sdk import set_tag
|
||||||
from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException # type: ignore
|
from SpiffWorkflow.bpmn.exceptions import WorkflowTaskExecException # type: ignore
|
||||||
from SpiffWorkflow.exceptions import WorkflowException # type: ignore
|
from SpiffWorkflow.exceptions import WorkflowException # type: ignore
|
||||||
from SpiffWorkflow.specs.base import TaskSpec # type: ignore
|
from SpiffWorkflow.specs.base import TaskSpec # type: ignore
|
||||||
@ -165,13 +165,12 @@ def set_user_sentry_context() -> None:
|
|||||||
username = "Unknown"
|
username = "Unknown"
|
||||||
# This is for sentry logging into Slack
|
# This is for sentry logging into Slack
|
||||||
sentry_sdk.set_context("User", {"user": username})
|
sentry_sdk.set_context("User", {"user": username})
|
||||||
set_user({"username": username})
|
set_tag("username", username)
|
||||||
|
|
||||||
|
|
||||||
@api_error_blueprint.app_errorhandler(Exception)
|
@api_error_blueprint.app_errorhandler(Exception)
|
||||||
def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
||||||
"""Handles unexpected exceptions."""
|
"""Handles unexpected exceptions."""
|
||||||
current_app.logger.exception(exception)
|
|
||||||
set_user_sentry_context()
|
set_user_sentry_context()
|
||||||
id = capture_exception(exception)
|
id = capture_exception(exception)
|
||||||
|
|
||||||
@ -183,6 +182,11 @@ def handle_exception(exception: Exception) -> flask.wrappers.Response:
|
|||||||
f"https://sentry.io/{organization_slug}/{project_slug}/events/{id}"
|
f"https://sentry.io/{organization_slug}/{project_slug}/events/{id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# !!!NOTE!!!: do this after sentry stuff since calling logger.exception
|
||||||
|
# seems to break the sentry sdk context where we no longer get back
|
||||||
|
# an event id or send out tags like username
|
||||||
|
current_app.logger.exception(exception)
|
||||||
|
|
||||||
# set api_exception like this to avoid confusing mypy
|
# set api_exception like this to avoid confusing mypy
|
||||||
# and what type the object is
|
# and what type the object is
|
||||||
api_exception = None
|
api_exception = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user