diff options
-rw-r--r-- | gn3/auth/authorisation/errors.py | 1 | ||||
-rw-r--r-- | gn3/errors.py | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/gn3/auth/authorisation/errors.py b/gn3/auth/authorisation/errors.py index fa2d6b7..89c5983 100644 --- a/gn3/auth/authorisation/errors.py +++ b/gn3/auth/authorisation/errors.py @@ -6,6 +6,7 @@ class AuthorisationError(Exception): All exceptions in this package should inherit from this class. """ + error_code: int = 500 class UserRegistrationError(AuthorisationError): """Raised whenever a user registration fails""" diff --git a/gn3/errors.py b/gn3/errors.py index 01f917e..4d41dc3 100644 --- a/gn3/errors.py +++ b/gn3/errors.py @@ -1,14 +1,15 @@ """Handle application level errors.""" -from flask import Flask, jsonify +from flask import Flask, jsonify, current_app from gn3.auth.authorisation.errors import AuthorisationError def handle_authorisation_error(exc: AuthorisationError): """Handle AuthorisationError if not handled anywhere else.""" + current_app.logger.error(exc) return jsonify({ "error": type(exc).__name__, "error_description": " :: ".join(exc.args) - }), 500 + }), exc.error_code def register_error_handlers(app: Flask): """Register application-level error handlers.""" |