Skip to content

Commit afa279f

Browse files
authored
Merge pull request #1064 from closeio/andrzej/p2/remove-broken-flask-error-handler
Remove a broken Flask error handler
2 parents 087508b + 06bc7ee commit afa279f

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

inbox/api/srv.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from flask import Flask, g, jsonify, make_response, request
44
from flask_restful import reqparse # type: ignore[import-untyped]
55
from sqlalchemy.orm.exc import NoResultFound # type: ignore[import-untyped]
6-
from werkzeug.exceptions import HTTPException, default_exceptions
76

87
from inbox.api.err import APIException, InputError, NotFoundError
98
from inbox.api.kellogs import APIEncoder
@@ -17,7 +16,6 @@
1716
from inbox.auth.generic import GenericAccountData, GenericAuthHandler
1817
from inbox.auth.google import GoogleAccountData, GoogleAuthHandler
1918
from inbox.auth.microsoft import MicrosoftAccountData, MicrosoftAuthHandler
20-
from inbox.logging import get_logger
2119
from inbox.models import Account, Namespace
2220
from inbox.models.backends.generic import GenericAccount
2321
from inbox.models.backends.gmail import GOOGLE_EMAIL_SCOPES, GmailAccount
@@ -50,26 +48,6 @@ def handle_input_error(error): # type: ignore[no-untyped-def] # noqa: ANN201
5048
return response
5149

5250

53-
def default_json_error(ex): # type: ignore[no-untyped-def] # noqa: ANN201
54-
"""Exception -> flask JSON responder"""
55-
logger = get_logger()
56-
logger.error("Uncaught error thrown by Flask/Werkzeug", exc_info=ex)
57-
response = jsonify(message=str(ex), type="api_error")
58-
response.status_code = (
59-
ex.code # type: ignore[assignment]
60-
if isinstance(ex, HTTPException)
61-
else 500
62-
)
63-
return response
64-
65-
66-
# Patch all error handlers in werkzeug
67-
for code in default_exceptions:
68-
app.error_handler_spec[None][
69-
code
70-
] = default_json_error # type: ignore[assignment]
71-
72-
7351
@app.before_request
7452
def auth(): # type: ignore[no-untyped-def] # noqa: ANN201
7553
"""Check for account ID on all non-root URLS"""

0 commit comments

Comments
 (0)