[Answered ]-Handlers for specific Exception

2👍

You should be able to achieve this by writing and registering a custom Django middleware class for your project.

In the middleware’s process_exception method, check for the exception you are interested in and generate an appropriate HttpResponse:

def process_exception(self, request, exception):
    if isinstance(exception, myException):
        return http.HttpResponse("myException raised")
    else:
        # Perform standard error handling for other exceptions:
        return None

Leave a comment