-
-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(api): move jsonResponse logic to APIInvalidInputException
- Loading branch information
1 parent
220fb2b
commit 66c0cf3
Showing
2 changed files
with
8 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
""" | ||
Classes for API errors | ||
""" | ||
from sefaria.client.util import jsonResponse | ||
|
||
|
||
class APIInvalidInputException(Exception): | ||
""" | ||
When data in an invalid format is passed to an API | ||
""" | ||
pass | ||
def __init__(self, message): | ||
super().__init__(message) | ||
self.message = message | ||
|
||
def to_json_response(self): | ||
return jsonResponse({"invalid_input_error": self.message}, status=400) |
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