Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Feb 25, 2025
1 parent 13492e8 commit 438da41
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def assert_status(
response.status_code == expected_status_code
), f"received {response.status_code}: {response.text}, expected {get_code_display_name(expected_status_code)}"

# reponse
# response
if expected_status_code == status.HTTP_204_NO_CONTENT:
assert response.text == ""
return None, None
Expand Down
14 changes: 14 additions & 0 deletions packages/service-library/src/servicelib/fastapi/http_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,17 @@ def set_app_default_http_error_handlers(app: FastAPI) -> None:
envelope_error=True,
),
)

# SEE https://docs.python.org/3/library/exceptions.html#exception-hierarchy
app.add_exception_handler(
NotImplementedError,
make_http_error_handler_for_exception(
status.HTTP_501_NOT_IMPLEMENTED, NotImplementedError, envelope_error=True
),
)
app.add_exception_handler(
Exception,
make_http_error_handler_for_exception(
status.HTTP_500_INTERNAL_SERVER_ERROR, Exception, envelope_error=True
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,3 @@ def set_exception_handlers(app: FastAPI) -> None:
envelope_error=True,
),
)

# SEE https://docs.python.org/3/library/exceptions.html#exception-hierarchy
app.add_exception_handler(
NotImplementedError,
make_http_error_handler_for_exception(
status.HTTP_501_NOT_IMPLEMENTED, NotImplementedError, envelope_error=True
),
)
app.add_exception_handler(
Exception,
make_http_error_handler_for_exception(
status.HTTP_500_INTERNAL_SERVER_ERROR, Exception, envelope_error=True
),
)

0 comments on commit 438da41

Please sign in to comment.