diff --git a/starlette/applications.py b/starlette/applications.py index ea52ee70e..0ea3efa47 100644 --- a/starlette/applications.py +++ b/starlette/applications.py @@ -5,6 +5,8 @@ from starlette.middleware import Middleware from starlette.middleware.base import BaseHTTPMiddleware from starlette.middleware.errors import ServerErrorMiddleware +from starlette.requests import Request +from starlette.responses import Response from starlette.routing import BaseRoute, Router from starlette.types import ASGIApp, Receive, Scope, Send @@ -129,7 +131,7 @@ def add_middleware(self, middleware_class: type, **options: typing.Any) -> None: def add_exception_handler( self, exc_class_or_status_code: typing.Union[int, typing.Type[Exception]], - handler: typing.Callable, + handler: typing.Callable[[Request, Exception], typing.Union[Response, typing.Coroutine[typing.Any, typing.Any, Response]]], ) -> None: self.exception_handlers[exc_class_or_status_code] = handler self.middleware_stack = self.build_middleware_stack()