-
-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error messaging and remove 500 errors #1972
base: master
Are you sure you want to change the base?
Improve error messaging and remove 500 errors #1972
Conversation
sefaria/system/decorators.py
Outdated
@@ -42,7 +42,10 @@ def wrapper(*args, **kwargs): | |||
except exps.InputError as e: | |||
logger.warning("An exception occurred processing request for '{}' while running {}. Caught as JSON".format(args[0].path, func.__name__), exc_info=True) | |||
request = args[0] | |||
return jsonResponse({"error": str(e)}, callback=request.GET.get("callback", None)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in the view, its too specific for a generic decorator
reader/views.py
Outdated
try: | ||
text = _get_text(oref, versionEn=versionEn, versionHe=versionHe, commentary=commentary, context=context, pad=pad, | ||
alts=alts, wrapLinks=wrapLinks, layer_name=layer_name) | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we discussed that we need to raise a proper error rather than do string comparison on the error message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I recall discussing that - and recall vaguely there being a reason we stuck with this. What would you recommend at this point?
api/views.py
Outdated
|
||
try: | ||
data = text_manager.get_versions_for_query() | ||
except InputError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see below?
Description
Improve error messaging and remove 500 errors on the texts API (v1 and v2)
Code Changes
sefaria/model/text.py
- Write more robust error message to be more helpful for our third party users.api/views.py
- Properly catch error for Book Level Complex Texts, and report helpful error message.