-
Notifications
You must be signed in to change notification settings - Fork 6
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
Return JSON for InternalServerErrors #19
base: master
Are you sure you want to change the base?
Conversation
|
||
INTERNAL_SERVER_ERROR_FALLBACK_MESSAGE = HIPO_DRF_SETTINGS.get( | ||
"INTERNAL_SERVER_ERROR_FALLBACK_MESSAGE", | ||
_('Our servers are unreachable at the moment. Please try again a few minutes later.') |
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.
We need to import gettext_lazy
as _
for the translation.
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.
Thank you, fixed.
hipo_drf_exceptions/exceptions.py
Outdated
@@ -1,7 +1,15 @@ | |||
from django.utils.translation import ugettext_lazy as _ |
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.
ugettext_lazy
is deprecated in Django 3.0 so it would be nice if we use gettext_lazy
here for the sake of compatibility.
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.
Thank you, fixed.
json_content_type = "application/json" | ||
response = get_response(request) | ||
|
||
if str(response.status_code).startswith("5") and request.content_type == json_content_type: |
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.
This converts all 5XX responses to 500. Should not we check the full status code instead of checking the first character?
@efe did you check these docs? Maybe we shouldn't have a middleware at all? |
Issue: #7