Skip to main content

get_exception_response

Resolves and executes the error handler for a given status code, falling back to a generic uncaught exception handler and triggering a failure signal if the primary callback fails.

def get_exception_response(
request: HttpRequest,
resolver: URLResolver,
status_code: int,
exception: Exception
) - > HttpResponse

Retrieves the appropriate HTTP response for a given status code and exception by invoking the registered error handler. If the error handler fails, it triggers a request exception signal and falls back to the uncaught exception handler.

Parameters

NameTypeDescription
requestHttpRequestThe current web request object being processed.
resolverURLResolverThe URL resolver used to locate the appropriate error handler callback for the given status code.
status_codeintThe HTTP status code (e.g., 404, 500) for which an error response is required.
exceptionExceptionThe exception instance that triggered the error response generation.

Returns

TypeDescription
HttpResponseThe response object generated by the resolved error handler or the fallback uncaught exception handler.