-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2560 from deniszh/backport/1.1.x/pr-2547_pr-2547_…
…pr-2547_pr-2547_pr-2547_pr-2555_pr-2555_pr-2554_pr-2554_pr-2556_pr-2557_pr-2557_pr-2558_pr-2559 [1.1.x] handle exceptions if params cannot be type converted (#2547) | fix minor bug in query param evaluation (#2547) | fails to instantiate find query must be due to bad user input (#2547) | add tests for invalid parameter types (#2547) |
- Loading branch information
Showing
23 changed files
with
349 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
from django.http import HttpResponseBadRequest | ||
|
||
|
||
class NormalizeEmptyResultError(Exception): | ||
# throw error for normalize() when empty | ||
pass | ||
|
||
|
||
class InputParameterError(ValueError): | ||
pass | ||
|
||
|
||
# decorator which turns InputParameterExceptions into Django's HttpResponseBadRequest | ||
def handleInputParameterError(f): | ||
def new_f(*args, **kwargs): | ||
try: | ||
return f(*args, **kwargs) | ||
except InputParameterError as e: | ||
return HttpResponseBadRequest('Bad Request: {err}'.format(err=e)) | ||
|
||
return new_f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.