Handle an exception that has been raised. This should forward :class:`~quart.exception.HTTPException` to :meth:`handle_http_exception`, then attempt to handle the error. If it cannot it should reraise the error.
(
self, error: Exception
)
| 1032 | return await self.ensure_async(handler)(error) # type: ignore[return-value] |
| 1033 | |
| 1034 | async def handle_user_exception( |
| 1035 | self, error: Exception |
| 1036 | ) -> HTTPException | ResponseReturnValue: |
| 1037 | """Handle an exception that has been raised. |
| 1038 | |
| 1039 | This should forward :class:`~quart.exception.HTTPException` to |
| 1040 | :meth:`handle_http_exception`, then attempt to handle the |
| 1041 | error. If it cannot it should reraise the error. |
| 1042 | """ |
| 1043 | if isinstance(error, BadRequestKeyError) and ( |
| 1044 | self.debug or self.config["TRAP_BAD_REQUEST_ERRORS"] |
| 1045 | ): |
| 1046 | error.show_exception = True |
| 1047 | |
| 1048 | if isinstance(error, HTTPException) and not self.trap_http_exception(error): |
| 1049 | return await self.handle_http_exception(error) |
| 1050 | |
| 1051 | blueprints = [] |
| 1052 | if has_request_context(): |
| 1053 | blueprints = request.blueprints |
| 1054 | elif has_websocket_context(): |
| 1055 | blueprints = websocket.blueprints |
| 1056 | |
| 1057 | handler = self._find_error_handler(error, blueprints) |
| 1058 | if handler is None: |
| 1059 | raise error |
| 1060 | return await self.ensure_async(handler)(error) # type: ignore[return-value] |
| 1061 | |
| 1062 | async def handle_exception(self, error: Exception) -> ResponseTypes: |
| 1063 | """Handle an uncaught exception. |
no test coverage detected