http_exception_handler
Handles HTTP exceptions by returning an appropriate Response or JSONResponse based on the exception's status code and detail, including any specified headers.
def http_exception_handler(
request: Request,
exc: HTTPException
) - > Response
Handles HTTP exceptions by returning an appropriate HTTP response. This function is used to standardize error responses for HTTP exceptions.
Parameters
| Name | Type | Description |
|---|---|---|
| request | Request | The incoming HTTP request object. |
| exc | HTTPException | The HTTP exception that was raised, containing details like status code and error message. |
Returns
| Type | Description |
|---|---|
Response | An HTTP response object, either a standard Response for status codes that do not allow a body, or a JSONResponse for others. |