Example #1
0
def _handle_errors(request, response):
    if response:
        code = "Http%s" % response
        msg = "%(code)s: %(response)s at %(uri)s" % {
                   'code': code,
                   'response': { 'Http403': "Forbidden",
                                 'Http404': "Page not found" }[code],
                   'uri': request.build_absolute_uri()
        }
        return (code, msg)
    
    exc, inst = sys.exc_info()[:2]
    return _class_name(inst), _parse_message(inst)
Example #2
0
def _handle_errors(request, response, exception):
    if response:
        code = "Http%s" % response
        msg = "%(code)s: %(response)s at %(uri)s" % {
                   'code': code,
                   'response': {'Http403': "Forbidden",
                                'Http404': "Page not found"}[code],
                   'uri': request.build_absolute_uri(),
        }
        return (code, msg)

    inst = exception
    if not exception:
        # basically, if we didn't pass in an exception, then
        # try to get the last traceback
        _exc, inst = sys.exc_info()[:2]

    return _class_name(inst), _parse_message(inst)