|
3 | 3 | from flask import Flask, g, jsonify, make_response, request |
4 | 4 | from flask_restful import reqparse # type: ignore[import-untyped] |
5 | 5 | from sqlalchemy.orm.exc import NoResultFound # type: ignore[import-untyped] |
6 | | -from werkzeug.exceptions import HTTPException, default_exceptions |
7 | 6 |
|
8 | 7 | from inbox.api.err import APIException, InputError, NotFoundError |
9 | 8 | from inbox.api.kellogs import APIEncoder |
|
17 | 16 | from inbox.auth.generic import GenericAccountData, GenericAuthHandler |
18 | 17 | from inbox.auth.google import GoogleAccountData, GoogleAuthHandler |
19 | 18 | from inbox.auth.microsoft import MicrosoftAccountData, MicrosoftAuthHandler |
20 | | -from inbox.logging import get_logger |
21 | 19 | from inbox.models import Account, Namespace |
22 | 20 | from inbox.models.backends.generic import GenericAccount |
23 | 21 | 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 |
50 | 48 | return response |
51 | 49 |
|
52 | 50 |
|
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 | | - |
73 | 51 | @app.before_request |
74 | 52 | def auth(): # type: ignore[no-untyped-def] # noqa: ANN201 |
75 | 53 | """Check for account ID on all non-root URLS""" |
|
0 commit comments