Skip to content

Commit

Permalink
fix(apis/web/plugin): don't wrap the error if it's from error_handler (
Browse files Browse the repository at this point in the history
  • Loading branch information
wklken authored Oct 18, 2023
1 parent f8c8cac commit 53b6036
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dashboard/apigateway/apigateway/common/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def render(self, data, accepted_media_type=None, renderer_context=None):
resp = renderer_context["response"]
if status.is_success(resp.status_code):
data = {"data": data}
elif status.is_client_error(resp.status_code) or status.is_server_error(resp.status_code):
elif (
status.is_client_error(resp.status_code) or status.is_server_error(resp.status_code)
) and "error" not in data:
# the error from exception_handler already wrap the error data, so we don't need to wrap it again
data = {"error": data}
# For status codes other than (2xx, 4xx, 5xx), do not wrap data
return super().render(data, accepted_media_type=None, renderer_context=None)

0 comments on commit 53b6036

Please sign in to comment.