File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 10
10
from sentry_sdk .integrations .logging import ignore_logger
11
11
12
12
from sanic import Sanic
13
+ from sanic .exceptions import SanicException
13
14
from sanic .router import Router
14
15
from sanic .handlers import ErrorHandler
15
16
@@ -94,6 +95,9 @@ async def sentry_wrapped_error_handler(request, exception):
94
95
95
96
96
97
def _capture_exception (exception ):
98
+ if isinstance (exception , SanicException ):
99
+ return
100
+
97
101
hub = Hub .current
98
102
integration = hub .get_integration (SanicIntegration )
99
103
if integration is None :
Original file line number Diff line number Diff line change 5
5
6
6
flask = pytest .importorskip ("flask" )
7
7
8
- from flask import Flask , request
8
+ from flask import Flask , request , abort
9
9
10
10
from flask_login import LoginManager , login_user
11
11
@@ -445,3 +445,18 @@ def error_handler(err):
445
445
446
446
exception , = event2 ["exception" ]["values" ]
447
447
assert exception ["type" ] == "ZeroDivisionError"
448
+
449
+
450
+ def test_bad_request_not_captured (sentry_init , capture_events , app ):
451
+ sentry_init (integrations = [flask_sentry .FlaskIntegration ()])
452
+ events = capture_events ()
453
+
454
+ @app .route ("/" )
455
+ def index ():
456
+ abort (400 )
457
+
458
+ client = app .test_client ()
459
+
460
+ client .get ("/" )
461
+
462
+ assert not events
Original file line number Diff line number Diff line change 7
7
from sentry_sdk .integrations .sanic import SanicIntegration
8
8
9
9
from sanic import Sanic , request , response
10
+ from sanic .exceptions import abort
10
11
11
12
12
13
@pytest .fixture
@@ -73,6 +74,20 @@ def myerror(request):
73
74
)
74
75
75
76
77
+ def test_bad_request_not_captured (sentry_init , app , capture_events ):
78
+ sentry_init (integrations = [SanicIntegration ()])
79
+ events = capture_events ()
80
+
81
+ @app .route ("/" )
82
+ def index (request ):
83
+ abort (400 )
84
+
85
+ request , response = app .test_client .get ("/" )
86
+ assert response .status == 400
87
+
88
+ assert not events
89
+
90
+
76
91
def test_error_in_errorhandler (sentry_init , app , capture_events ):
77
92
sentry_init (integrations = [SanicIntegration ()])
78
93
events = capture_events ()
You can’t perform that action at this time.
0 commit comments