client_request_error_handler¶
- async safir.fastapi.client_request_error_handler(request, exc)¶
Exception handler for exceptions derived from
ClientRequestError
.- Parameters:
request (
Request
) – Request that gave rise to the exception.exc (
ClientRequestError
) – Exception.
- Returns:
Serialization of the exception following
ErrorModel
, which is compatible with the serialization format used internally by FastAPI.- Return type:
fastapi.JSONResponse
Examples
This function should be installed as a global exception handler for a FastAPI app:
from safir.fastapi import ( ClientRequestError, client_request_error_handler, ) app.exception_handler(ClientRequestError)(client_request_error_handler)