# Buggy code
async def handle_request(self, request, write_callback, stream_callback):
    """Take a request from the HTTP Server and return a response object
    to be sent back The HTTP Server only expects a response object, so
    exception handling must be done here

    :param request: HTTP Request object
    :param write_callback: Synchronous response function to be
        called with the response as the only argument
    :param stream_callback: Coroutine that handles streaming a
        StreamingHTTPResponse if produced by the handler.

    :return: Nothing
    """
    try:
        # -------------------------------------------- #
        # Request Middleware
        # -------------------------------------------- #

        request.app = self
        response = await self._run_request_middleware(request)
        # No middleware results
        if not response:
            # -------------------------------------------- #
            # Execute Handler
            # -------------------------------------------- #

            # Fetch handler from router
            handler, args, kwargs, uri = self.router.get(request)

            request.uri_template = uri
            if handler is None:
                raise ServerError(
                    ("'None' was returned while requesting a handler from the router")
                )

            # Run response handler
            response = handler(request, *args, **kwargs)
            if isawaitable(response):
                response = await response
    except Exception as e:
        # -------------------------------------------- #
        # Response Generation Failed
        # -------------------------------------------- #

        try:
            response = self.error_handler.response(request, e)
            if isawaitable(response):
                response = await response
        except Exception as e:
            if self.debug:
                response = HTTPResponse(
                    "Error while handling error: {}\nStack: {}".format(e, format_exc())
                )
            else:
                response = HTTPResponse("An error occurred while handling an error")
    finally:
        # -------------------------------------------- #
        # Response Middleware
        # -------------------------------------------- #
        try:
            response = await self._run_response_middleware(request, response)
        except BaseException:
            error_logger.exception(
                "Exception occurred in one of response middleware handlers"
            )

    # pass the response to the correct callback
    if isinstance(response, StreamingHTTPResponse):
        await stream_callback(response)
    else:
        write_callback(response)


# Traceback (FileNotFoundError)
Error while handling error: File not found
Stack: Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sanic/static.py", line 76, in _handler
stats = await stat(file_path)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 213, in coro
res = yield from res
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/rob/git/GITHUB/zzzz-server/scripts/static/favicon.ico'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sanic/app.py", line 565, in handle_request
response = await response
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 109, in __next__
return self.gen.send(None)
File "/Users/rob/git/GITHUB/zzzz-server/scripts/dummy.py", line 21, in catch_all
raise exception
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sanic/app.py", line 556, in handle_request
response = await response
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/coroutines.py", line 128, in throw
return self.gen.throw(type, value, traceback)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sanic/static.py", line 120, in _handler
relative_url=file_uri)
sanic.exceptions.FileNotFound: File not found

# Fixed code
async def handle_request(self, request, write_callback, stream_callback):
    """Take a request from the HTTP Server and return a response object
    to be sent back The HTTP Server only expects a response object, so
    exception handling must be done here

    :param request: HTTP Request object
    :param write_callback: Synchronous response function to be
        called with the response as the only argument
    :param stream_callback: Coroutine that handles streaming a
        StreamingHTTPResponse if produced by the handler.

    :return: Nothing
    """
    try:
        # -------------------------------------------- #
        # Request Middleware
        # -------------------------------------------- #

        request.app = self
        response = await self._run_request_middleware(request)
        # No middleware results
        if not response:
            # -------------------------------------------- #
            # Execute Handler
            # -------------------------------------------- #

            # Fetch handler from router
            handler, args, kwargs, uri = self.router.get(request)

            request.uri_template = uri
            if handler is None:
                raise ServerError(
                    ("'None' was returned while requesting a handler from the router")
                )

            # Run response handler
            response = handler(request, *args, **kwargs)
            if isawaitable(response):
                response = await response
    except Exception as e:
        # -------------------------------------------- #
        # Response Generation Failed
        # -------------------------------------------- #

        try:
            response = self.error_handler.response(request, e)
            if isawaitable(response):
                response = await response
        except Exception as e:
            if isinstance(e, SanicException):
                response = self.error_handler.default(request=request, exception=e)
            elif self.debug:
                response = HTTPResponse(
                    "Error while handling error: {}\nStack: {}".format(e, format_exc()),
                    status=500,
                )
            else:
                response = HTTPResponse(
                    "An error occurred while handling an error", status=500
                )
    finally:
        # -------------------------------------------- #
        # Response Middleware
        # -------------------------------------------- #
        try:
            response = await self._run_response_middleware(request, response)
        except BaseException:
            error_logger.exception(
                "Exception occurred in one of response middleware handlers"
            )

    # pass the response to the correct callback
    if isinstance(response, StreamingHTTPResponse):
        await stream_callback(response)
    else:
        write_callback(response)