Handle an uncaught exception during request processing, returning a 500 response.
(self, event: Dict[str, Any], context: Any, exception: Exception)
| 316 | return exception_processed |
| 317 | |
| 318 | def _handle_request_exception(self, event: Dict[str, Any], context: Any, exception: Exception) -> Dict[str, Any]: |
| 319 | """Handle an uncaught exception during request processing, returning a 500 response.""" |
| 320 | print(exception) |
| 321 | exc_info = sys.exc_info() |
| 322 | message = ( |
| 323 | "An uncaught exception happened while servicing this request. " |
| 324 | "You can investigate this with the `zappa tail` command." |
| 325 | ) |
| 326 | |
| 327 | settings = self.settings |
| 328 | if settings is not None: |
| 329 | self._process_exception( |
| 330 | exception_handler=settings.EXCEPTION_HANDLER, |
| 331 | event=event, |
| 332 | context=context, |
| 333 | exception=exception, |
| 334 | ) |
| 335 | |
| 336 | content: Dict[str, Any] = collections.OrderedDict() |
| 337 | content["statusCode"] = 500 |
| 338 | body: Dict[str, Any] = {"message": message} |
| 339 | if settings is not None and settings.DEBUG: |
| 340 | body["traceback"] = traceback.format_exception(*exc_info) |
| 341 | content["body"] = json.dumps(str(body), sort_keys=True, indent=4) |
| 342 | return content |
| 343 | |
| 344 | @staticmethod |
| 345 | def _process_response_body(response: Response, settings: ModuleType) -> Tuple[str, bool]: |
no test coverage detected