def error_handler_401(error): # set the cors headers explicity since the error handler use a fresh request from bauble.routes import set_cors_headers set_cors_headers() if request.auth: user, password = request.auth return "Could not authorize user: {user}".format(user=user) else: return "No Authorization header."
def default_error_handler(error): # TODO: only print the error when the debug flag is set # make sure the error is printed in the log if response.status_code >= 400 and response.status_code <= 599: print('error.status: ', error.status) print('error.body: ', error.body) from bauble.routes import set_cors_headers set_cors_headers() if isinstance(error, str): return error elif error.body is not None: return str(error.body)
def wrapper(*args, **kwargs): set_cors_headers() return callback(*args, **kwargs)