MCPcopy
hub / github.com/django/django / handle_uncaught_exception

Method handle_uncaught_exception

django/core/handlers/asgi.py:286–296  ·  view source on GitHub ↗

Last-chance handler for exceptions.

(self, request, resolver, exc_info)

Source from the content-addressed store, hash-verified

284 return None, HttpResponse("413 Payload too large", status=413)
285
286 def handle_uncaught_exception(self, request, resolver, exc_info):
287 """Last-chance handler for exceptions."""
288 # There's no WSGI server to catch the exception further up
289 # if this fails, so translate it into a plain text response.
290 try:
291 return super().handle_uncaught_exception(request, resolver, exc_info)
292 except Exception:
293 return HttpResponseServerError(
294 traceback.format_exc() if settings.DEBUG else "Internal Server Error",
295 content_type="text/plain",
296 )
297
298 async def send_response(self, response, send):
299 """Encode and send a response out over ASGI."""

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected