Skip to content

Commit 3bd5cc9

Browse files
committed
mypy
1 parent 3951cb2 commit 3bd5cc9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/service-library/src/servicelib/fastapi/http_error.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ async def _http_error_handler(_: Request, exc: Exception) -> JSONResponse:
4242
"errors": error_extractor(exc) if error_extractor else [f"{exc}"]
4343
}
4444

45-
if envelope_error:
46-
error_content = {"error": error_content}
4745
return JSONResponse(
48-
content=jsonable_encoder(error_content),
46+
content=jsonable_encoder(
47+
{"error": error_content} if envelope_error else error_content
48+
),
4949
status_code=status_code,
5050
)
5151

@@ -65,10 +65,11 @@ async def _http_error_handler(_: Request, exc: Exception) -> JSONResponse:
6565
assert isinstance(exc, HTTPException)
6666

6767
error_content = {"errors": [exc.detail]}
68-
if envelope_error:
69-
error_content = {"error": error_content}
68+
7069
return JSONResponse(
71-
content=jsonable_encoder(error_content),
70+
content=jsonable_encoder(
71+
{"error": error_content} if envelope_error else error_content
72+
),
7273
status_code=exc.status_code,
7374
)
7475

0 commit comments

Comments
 (0)