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

@@ -6,6 +6,7 @@ from sqlalchemy.exc import SQLAlchemyError, DataError
from sqlalchemy.orm.exc import NoResultFound
from marshmallow import ValidationError
from app.authentication.auth import AuthError
from app.notifications import SendNotificationToQueueError
class InvalidRequest(Exception):
@@ -83,6 +84,11 @@ def register_errors(blueprint):
current_app.logger.exception(e)
return jsonify(result='error', message="No result found"), 404
@blueprint.errorhandler(SendNotificationToQueueError)
def failed_to_create_notification(e):
current_app.logger.exception(e)
return jsonify(result='error', message=e.message), 500
@blueprint.errorhandler(SQLAlchemyError)
def db_error(e):
current_app.logger.exception(e)