Attempts to render a template based on the `code` of a `HTTPException`. The
    format string `errors/{code}.html` is used to generate the filename of
    the template.

    e.g. A `NotFound` exception will attempt to render `errors/404.html`.

    If no template is found the standard flask error response is returned.

def handle_http_exception(error):
    """
    Attempts to render a template based on the `code` of a `HTTPException`. The
    format string `errors/{code}.html` is used to generate the filename of
    the template.

    e.g. A `NotFound` exception will attempt to render `errors/404.html`.

    If no template is found the standard flask error response is returned.
    """
    template = TEMPLATE.format(code=error.code)

    try:
        return flask.render_template(template, exception=error), error.code
    except jinja2.exceptions.TemplateNotFound:
        pass

    return error