Skip to content
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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

saengel
Copy link
Contributor

@saengel saengel commented Jul 17, 2024

Description

Improve error messaging and remove 500 errors on the texts API (v1 and v2)

Code Changes

  1. sefaria/model/text.py - Write more robust error message to be more helpful for our third party users.
  2. api/views.py - Properly catch error for Book Level Complex Texts, and report helpful error message.

@@ -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))
Copy link
Contributor

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see below?

@saengel saengel requested review from edamboritz and yitzhakc and removed request for nsantacruz November 11, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants