properly handle exceptions in middleware signals
This commit is contained in:
parent
db282465d7
commit
cac58a3f80
|
@ -124,12 +124,8 @@ class Application(Generic[R, RT, AT]):
|
||||||
response: Response | None = None
|
response: Response | None = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.on_request.handle_emit(request)
|
await self.on_request.handle_emit(request, catch_errors = False)
|
||||||
|
|
||||||
except Exception as error:
|
|
||||||
response = self._handle_error(request, error)
|
|
||||||
|
|
||||||
try:
|
|
||||||
match = self.router(request.path, request.method)
|
match = self.router(request.path, request.method)
|
||||||
request.params = match.params or {} # type: ignore[assignment]
|
request.params = match.params or {} # type: ignore[assignment]
|
||||||
response = await match.target(request)
|
response = await match.target(request)
|
||||||
|
@ -141,7 +137,7 @@ class Application(Generic[R, RT, AT]):
|
||||||
response = self._handle_error(request, error)
|
response = self._handle_error(request, error)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await self.on_response.handle_emit(request, response)
|
await self.on_response.handle_emit(request, response, catch_errors = False)
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
response = self._handle_error(request, error)
|
response = self._handle_error(request, error)
|
||||||
|
|
Loading…
Reference in a new issue