mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-23 00:41:35 -05:00
Change endpoint responses where there are marshalling, unmarshalling
or param errors to raise invalid data exception. That will cause those responses to be handled in by errors.py, which will log the errors. Set most of schemas to strict mode so that marshmallow will raise exception rather than checking for errors in return tuple from load. Added handler to errors.py for marshmallow validation errors.
This commit is contained in:
@@ -10,7 +10,11 @@ from notifications_utils.url_safe_token import check_token
|
||||
|
||||
from app.dao.invited_user_dao import get_invited_user_by_id
|
||||
|
||||
from app.errors import register_errors
|
||||
from app.errors import (
|
||||
register_errors,
|
||||
InvalidRequest
|
||||
)
|
||||
|
||||
from app.schemas import invited_user_schema
|
||||
|
||||
|
||||
@@ -30,7 +34,8 @@ def get_invited_user_by_token(token):
|
||||
max_age_seconds)
|
||||
except SignatureExpired:
|
||||
message = 'Invitation with id {} expired'.format(invited_user_id)
|
||||
return jsonify(result='error', message=message), 400
|
||||
errors = {'invitation': [message]}
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
invited_user = get_invited_user_by_id(invited_user_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user