Handle exceptions during request processing.
(
self, error: Exception, scope: Scope, receive: Receive, send: Send
)
| 187 | return timing_information |
| 188 | |
| 189 | async def _handle_error( |
| 190 | self, error: Exception, scope: Scope, receive: Receive, send: Send |
| 191 | ) -> None: |
| 192 | """Handle exceptions during request processing.""" |
| 193 | if isinstance(error, PreventUpdate): |
| 194 | response = Response(status_code=204) |
| 195 | elif self.dash_server.error_handling_mode in ["raise", "prune"]: |
| 196 | tb = self.dash_server._get_traceback(None, error) # pylint: disable=W0212 |
| 197 | response = Response(content=tb, media_type="text/html", status_code=500) |
| 198 | else: |
| 199 | response = JSONResponse( |
| 200 | status_code=500, |
| 201 | content={ |
| 202 | "error": "InternalServerError", |
| 203 | "message": "An internal server error occurred.", |
| 204 | }, |
| 205 | ) |
| 206 | await response(scope, receive, send) |
| 207 | |
| 208 | async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
| 209 | # Handle lifespan events (startup/shutdown) |
no test coverage detected