Now that we have discovered that the catch all Exception handler doesn't work, I've created a custom exception (SendNotificationQueueError) that handles this case and an error handler for it.

Talked these through with @becca as an approach.
This commit is contained in:
Martyn Inglis
2016-11-21 15:11:19 +00:00
parent 7cfc58c994
commit 58bbc5a5aa
6 changed files with 27 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ from sqlalchemy.exc import DataError
from sqlalchemy.orm.exc import NoResultFound
from app.authentication.auth import AuthError
from app.errors import InvalidRequest
from app.notifications import SendNotificationToQueueError
class TooManyRequestsError(InvalidRequest):
@@ -47,6 +48,13 @@ def register_errors(blueprint):
def auth_error(error):
return jsonify(error.to_dict_v2()), error.code
@blueprint.errorhandler(SendNotificationToQueueError)
def failed_to_create_notification(error):
current_app.logger.exception(error)
return jsonify(
status_code=500,
errors=[{"error": error.__class__.__name__, "message": error.message}]), 500
@blueprint.errorhandler(Exception)
def internal_server_error(error):
current_app.logger.exception(error)