aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
Diffstat (limited to 'gn3')
-rw-r--r--gn3/errors.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/gn3/errors.py b/gn3/errors.py
index 1833bf6..42b5788 100644
--- a/gn3/errors.py
+++ b/gn3/errors.py
@@ -15,6 +15,7 @@ from werkzeug.exceptions import NotFound
from authlib.oauth2.rfc6749.errors import OAuth2Error
from flask import Flask, jsonify, Response, current_app
+from gn3.oauth2 import errors as oautherrors
from gn3.auth.authorisation.errors import AuthorisationError
@@ -106,6 +107,15 @@ def handle_generic(exc: Exception) -> Response:
return resp
+def handle_local_authorisation_errors(exc: oautherrors.AuthorisationError):
+ """Handle errors relating to authorisation that are raised locally."""
+ current_app.logger.error("Handling local auth errors", exc_info=True)
+ return jsonify(add_trace(exc, {
+ "error": type(exc).__name__,
+ "error_description": " ".join(exc.args)
+ })), 400
+
+
def register_error_handlers(app: Flask):
"""Register application-level error handlers."""
app.register_error_handler(NotFound, page_not_found)