SlackRouteErrorHandler#
- class gafaelfawr.slack.SlackRouteErrorHandler(path, endpoint, *, response_model=<fastapi.datastructures.DefaultPlaceholder object>, status_code=None, tags=None, dependencies=None, summary=None, description=None, response_description='Successful Response', responses=None, deprecated=None, name=None, methods=None, operation_id=None, response_model_include=None, response_model_exclude=None, response_model_by_alias=True, response_model_exclude_unset=False, response_model_exclude_defaults=False, response_model_exclude_none=False, include_in_schema=True, response_class=<fastapi.datastructures.DefaultPlaceholder object>, dependency_overrides_provider=None, callbacks=None, openapi_extra=None, generate_unique_id_function=<fastapi.datastructures.DefaultPlaceholder object>)#
Bases:
APIRouteCustom
fastapi.routing.APIRoutethat reports exceptions to Slack.Dynamically wrap FastAPI route handlers in an exception handler that reports uncaught exceptions (other than
fastapi.HTTPException,fastapi.exceptions.RequestValidationError,starlette.exceptions.HTTPException, and exceptions inheriting fromSlackIgnoredException) to Slack.Examples
Specify this class when creating a router. All uncaught exceptions from handlers managed by that router will be reported to Slack, if Slack alerts are configured.
router = APIRouter(route_class=SlackRouteErrorHandler)
Notes
Based on this StackOverflow question.
- Parameters:
path (
str) –response_model (
Any, default:<fastapi.datastructures.DefaultPlaceholder object at 0x7fa783454d90>) –response_description (
str, default:'Successful Response') –responses (
Optional[Dict[Union[int,str],Dict[str,Any]]], default:None) –response_model_include (
Union[Set[Union[int,str]],Dict[Union[int,str],Any],None], default:None) –response_model_exclude (
Union[Set[Union[int,str]],Dict[Union[int,str],Any],None], default:None) –response_model_by_alias (
bool, default:True) –response_model_exclude_unset (
bool, default:False) –response_model_exclude_defaults (
bool, default:False) –response_model_exclude_none (
bool, default:False) –include_in_schema (
bool, default:True) –response_class (
Union[Type[Response],DefaultPlaceholder], default:<fastapi.datastructures.DefaultPlaceholder object at 0x7fa783454e10>) –dependency_overrides_provider (
Optional[Any], default:None) –generate_unique_id_function (
Union[Callable[[APIRoute],str],DefaultPlaceholder], default:<fastapi.datastructures.DefaultPlaceholder object at 0x7fa783454d10>) –
Methods Summary
Wrap route handler with an exception handler.
Methods Documentation