Пример #1
0
def _error_page(status, message, traceback, version):
    # Don't show tracebacks to end users.
    if not handlers.is_dev_server() and not users.is_current_user_admin():
        traceback = None

    return str(
        handlers.render(
            "error", status=status, message=message, traceback=traceback, layout={"title": "Error %s" % status}
        )
    )
Пример #2
0
def _error_page(status, message, traceback, version):
    # Don't show tracebacks to end users.
    if not handlers.is_dev_server() and not users.is_current_user_admin():
        traceback = None

    if handlers.request().is_json:
        handlers.JsonError(status, message).set_response()
        return cherrypy.response.body

    return str(handlers.render('error',
        status=status,
        message=message,
        traceback=traceback,
        layout={'title': 'Error %s' % status}))
Пример #3
0
def _error_page(status, message, traceback, version):
    # Don't show tracebacks to end users.
    if not handlers.is_dev_server() and not users.is_current_user_admin():
        traceback = None

    if handlers.request().is_json:
        cherrypy.response.headers['Content-Type'] = 'application/json'
        return json.dumps({'error': {'message': message}})

    return str(handlers.render('error',
        status=status,
        message=message,
        traceback=traceback,
        layout={'title': 'Error %s' % status}))
Пример #4
0
def _error_page(status, message, traceback, version):
    # Don't show tracebacks to end users.
    if not handlers.is_dev_server() and not users.is_current_user_admin():
        traceback = None

    if handlers.request().is_json:
        handlers.JsonError(status, message).set_response()
        return cherrypy.response.body

    return str(
        handlers.render('error',
                        status=status,
                        message=message,
                        traceback=traceback,
                        layout={'title': 'Error %s' % status}))