|
19 | 19 |
|
20 | 20 | from sentry_sdk._types import Event, EventProcessor |
21 | 21 |
|
22 | | -# In Falcon 3.0 `falcon.api_helpers` is renamed to `falcon.app_helpers` |
23 | | -# and `falcon.API` to `falcon.App` |
24 | 22 |
|
25 | 23 | try: |
26 | 24 | import falcon # type: ignore |
|
29 | 27 | except ImportError: |
30 | 28 | raise DidNotEnable("Falcon not installed") |
31 | 29 |
|
32 | | -try: |
33 | | - import falcon.app_helpers # type: ignore |
34 | | - |
35 | | - falcon_helpers = falcon.app_helpers |
36 | | - falcon_app_class = falcon.App |
37 | | - FALCON3 = True |
38 | | -except ImportError: |
39 | | - import falcon.api_helpers # type: ignore |
| 30 | +import falcon.app_helpers # type: ignore |
40 | 31 |
|
41 | | - falcon_helpers = falcon.api_helpers |
42 | | - falcon_app_class = falcon.API |
43 | | - FALCON3 = False |
| 32 | +falcon_helpers = falcon.app_helpers |
| 33 | +falcon_app_class = falcon.App |
44 | 34 |
|
45 | 35 |
|
46 | 36 | _FALCON_UNSET = None # type: Optional[object] |
47 | | -if FALCON3: # falcon.request._UNSET is only available in Falcon 3.0+ |
48 | | - with capture_internal_exceptions(): |
49 | | - from falcon.request import _UNSET as _FALCON_UNSET # type: ignore[import-not-found, no-redef] |
| 37 | +with capture_internal_exceptions(): |
| 38 | + from falcon.request import _UNSET as _FALCON_UNSET # type: ignore[import-not-found, no-redef] |
50 | 39 |
|
51 | 40 |
|
52 | 41 | class FalconRequestExtractor(RequestExtractor): |
@@ -232,14 +221,7 @@ def _exception_leads_to_http_5xx(ex, response): |
232 | 221 | ex, (falcon.HTTPError, falcon.http_status.HTTPStatus) |
233 | 222 | ) |
234 | 223 |
|
235 | | - # We only check the HTTP status on Falcon 3 because in Falcon 2, the status on the response |
236 | | - # at the stage where we capture it is listed as 200, even though we would expect to see a 500 |
237 | | - # status. Since at the time of this change, Falcon 2 is ca. 4 years old, we have decided to |
238 | | - # only perform this check on Falcon 3+, despite the risk that some handled errors might be |
239 | | - # reported to Sentry as unhandled on Falcon 2. |
240 | | - return (is_server_error or is_unhandled_error) and ( |
241 | | - not FALCON3 or _has_http_5xx_status(response) |
242 | | - ) |
| 224 | + return (is_server_error or is_unhandled_error) and _has_http_5xx_status(response) |
243 | 225 |
|
244 | 226 |
|
245 | 227 | def _has_http_5xx_status(response): |
|
0 commit comments