'Pass the exception to the exception middleware. If no middleware
return a response for this exception, raise it.'

def process_exception_by_middleware(self, exception, request):

    for middleware_method in self._exception_middleware:
        response = middleware_method(request, exception)
        if response:
            return response
    raise
