def error(message=None, status=None, headers=None, request=None, debug=None):
    """
    Return a very simple error page, defaulting to a ``404 Not Found`` error if
    no status code is supplied. Usually, you'll want to call :func:`abort` in
    your code, rather than error(). Usage::

        return error(404)
        return error("Some message.", 404)
        return error("Blah blah blah.", 403, {'Some-Header': 'Fish'})
    """
    if request is None:
        request = Application.current_app.request

    if status is None:
        if isinstance(message, (int, long)):
            status, message = message, None
        else:
            status = 404

    status_text = None
    if isinstance(status, basestring):
        status, _, status_text = status.partition(' ')
        status = int(status)
    if not status_text:
        status_text = HTTP.get(status, "Unknown Error")

    if not headers:
        headers = {}

    if message is None:
        message = HTTP_MESSAGES.get(status, u"An unknown error has occurred.")
        values = request.__dict__.copy()
        values['url'] = decode(urllib.unquote(values['url']))
        message = message.format(**values)

    if status in HAIKUS:
        haiku = u'<div class="haiku">%s</div>' % HAIKUS[status]
    else:
        haiku = u""

    if not message[0] == u"<":
        message = u"<p>%s</p>" % message

    if debug is None:
        debug = Application.current_app and Application.current_app.debug

    if debug:
        debug = u"%0.3f ms" % (1000 * request.time)
    else:
        debug = u""

    result = ERROR_PAGE.safe_substitute(
        status=status,
        status_text=status_text,
        status_text_nbsp=status_text.replace(u" ", u"&nbsp;"),
        haiku=haiku,
        content=message,
        scheme=request.scheme,
        host=request.host,
        debug=debug
    )

    return result, status, headers
dataset/ETHPy150Open ecdavis/pants/pants/web/application.py/error/original