File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
packages/service-library/src/servicelib/aiohttp Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -87,14 +87,18 @@ def _handle_http_error(
8787) -> web .HTTPError :
8888 """Handle standard HTTP errors by ensuring they're properly formatted."""
8989 assert request # nosec
90+ assert not exception .empty_body , "HTTPError should not have an empty body" # nosec
91+
9092 exception .content_type = MIMETYPE_APPLICATION_JSON
9193 if exception .reason :
9294 exception .set_status (
9395 exception .status , safe_status_message (message = exception .reason )
9496 )
9597
9698 if not exception .text or not is_enveloped_from_text (exception .text ):
97- error_message = exception .text or exception .reason or "Unexpected error"
99+ # NOTE: aiohttp.HTTPException creates `text = f"{self.status}: {self.reason}"`
100+ # We do not like for the user to pop up a message like "401: You are not authorized"
101+ error_message = exception .reason or exception .text or "Unexpected error"
98102 error_model = ErrorGet (
99103 errors = [
100104 ErrorItemType .from_error (exception ),
You can’t perform that action at this time.
0 commit comments