def bad_request(error): """Raise if the browser sends something to the application the application or server cannot handle.""" app.logger.critical("Path: {}".format(request.path)) app.logger.critical(logging.exception("Exception")) message = "Something went wrong!" return errorhandler(500, message)
def not_found(error): """Raise if a resource does not exist and never existed. If we are running App locally, we have to avoid calling context processors and thus we return just an empty string.""" if DEBUG == False: return render_template('error/404.html'), 404 if request.path.startswith('/static/'): return '', 404 message = "Raise if a resource does not exist and never existed." return errorhandler(404, message)
def request_too_large(error): """Like 413 but for too long URLs.""" message = '413 - Error caught in {1} : {0}'.format(error, request.path) app.logger.critical(message) return errorhandler(408, message)
def request_timeout(error): """Raise to signalize a timeout.""" message = '408 - Error caught in {1} : {0}'.format(error, request.path) app.logger.critical(message) return errorhandler(408, message)
def not_found(error): """The method is not allowed for the requested URL.""" message = "Method Not Allowed" return errorhandler(405, message)
def unauthorized(error): """Raise if the user is not authorized. Also used if you want to use HTTP basic auth.""" message = "Raise if the user is not authorized. Also used if you want to use HTTP basic auth." return errorhandler(401, message)
def bad_request(error): """Raise if the browser sends something to the application the application or server cannot handle.""" message = "Raise if the browser sends something to the " message += "application the application or server cannot handle." return errorhandler(400, message)