11from __future__ import annotations
22
33from collections .abc import Mapping
4- from typing import Any , Callable
4+ from typing import Any
55
66from starlette ._exception_handler import (
77 ExceptionHandlers ,
1111from starlette .exceptions import HTTPException , WebSocketException
1212from starlette .requests import Request
1313from starlette .responses import PlainTextResponse , Response
14- from starlette .types import ASGIApp , Receive , Scope , Send
14+ from starlette .types import ASGIApp , ExceptionHandler , Receive , Scope , Send
1515from starlette .websockets import WebSocket
1616
1717
1818class ExceptionMiddleware :
1919 def __init__ (
2020 self ,
2121 app : ASGIApp ,
22- handlers : Mapping [Any , Callable [[ Request , Exception ], Response ] ] | None = None ,
22+ handlers : Mapping [Any , ExceptionHandler ] | None = None ,
2323 debug : bool = False ,
2424 ) -> None :
2525 self .app = app
@@ -36,7 +36,7 @@ def __init__(
3636 def add_exception_handler (
3737 self ,
3838 exc_class_or_status_code : int | type [Exception ],
39- handler : Callable [[ Request , Exception ], Response ] ,
39+ handler : ExceptionHandler ,
4040 ) -> None :
4141 if isinstance (exc_class_or_status_code , int ):
4242 self ._status_handlers [exc_class_or_status_code ] = handler
0 commit comments