Skip to content

Commit

Permalink
#39: Handle exception and send response
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Sep 18, 2019
1 parent 31e5b6e commit b755af3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def __init__(self, included_filters):

def apply_filter(self, query):
if not query.include_related_entities:
query.include_related_entities = True
query.include_related_entities = True
else:
raise MultipleIncludeError("Attempted multiple includes on a single query")

Expand Down
6 changes: 4 additions & 2 deletions common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from common.database_helpers import QueryFilterFactory
from common.exceptions import MissingRecordError, BadFilterError, AuthenticationError, BadRequestError, \
MissingCredentialsError
MissingCredentialsError, MultipleIncludeError
from common.models.db_models import SESSION
from common.session_manager import session_manager

Expand Down Expand Up @@ -63,6 +63,9 @@ def wrapper_gets_records(*args, **kwargs):
except MissingRecordError as e:
log.exception(e)
return "No such record in table", 404
except MultipleIncludeError as e:
log.exception(e)
return "Bad request, only one include filter may be given per request", 400
except BadFilterError as e:
log.exception(e)
return "Invalid filter requested", 400
Expand All @@ -78,7 +81,6 @@ def wrapper_gets_records(*args, **kwargs):
except BadRequestError as e:
log.exception(e)
return "Bad request", 400

return wrapper_gets_records


Expand Down

0 comments on commit b755af3

Please sign in to comment.