mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user