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

Bug fix: For a javascript ajax call, set the return code instead of default 200 in error view exception handler #1637

Merged
merged 3 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion deploy-board/deploy_board/webapp/error_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ def process_exception(self, request, exception):
# Error is displayed as a fragment over related feature area
if request.is_ajax():
ajax_vars = {'success': False, 'error': str(exception)}
return HttpResponse(json.dumps(ajax_vars), content_type='application/javascript')
ret = 500
if isinstance(exception, NotAuthorizedException):
ret = 403
elif isinstance(exception, FailedAuthenticationException):
ret = 401
return HttpResponse(json.dumps(ajax_vars), status=ret, content_type='application/javascript')
else:
# Not authorized
if isinstance(exception, NotAuthorizedException):
Expand Down
Loading