Fix the response codes for errors.
This commit is contained in:
parent
1af43735d0
commit
fff5da6354
3 changed files with 0 additions and 50 deletions
|
@ -55,30 +55,6 @@ def csrf_protect():
|
|||
req_user)
|
||||
|
||||
|
||||
@api.errorhandler(404)
|
||||
def endpoint_not_found(e):
|
||||
return jsonify({
|
||||
'error_code': 404,
|
||||
'message': 'Resource not found'
|
||||
})
|
||||
|
||||
|
||||
@api.errorhandler(403)
|
||||
def endpoint_forbidden(e):
|
||||
return jsonify({
|
||||
'error_code': 403,
|
||||
'message': 'Permission Denied'
|
||||
})
|
||||
|
||||
|
||||
@api.errorhandler(400)
|
||||
def endpoint_invalid_request(e):
|
||||
return jsonify({
|
||||
'error_code': 400,
|
||||
'message': 'Invalid Request'
|
||||
})
|
||||
|
||||
|
||||
def request_error(exception=None, **kwargs):
|
||||
data = kwargs.copy()
|
||||
if exception:
|
||||
|
|
|
@ -55,19 +55,6 @@ def generate_headers(role='read'):
|
|||
return decorator_method
|
||||
|
||||
|
||||
@index.errorhandler(404)
|
||||
def fallback_not_found(e):
|
||||
return make_response('Not Found', 404)
|
||||
|
||||
@index.errorhandler(403)
|
||||
def fallback_forbidden(e):
|
||||
return make_response('Forbidden', 403)
|
||||
|
||||
@index.errorhandler(400)
|
||||
def fallback_invalid_request(e):
|
||||
return make_response('Invalid Request', 400)
|
||||
|
||||
|
||||
@index.route('/users', methods=['POST'])
|
||||
@index.route('/users/', methods=['POST'])
|
||||
def create_user():
|
||||
|
|
|
@ -23,19 +23,6 @@ store = app.config['STORAGE']
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@registry.errorhandler(404)
|
||||
def fallback_not_found(e):
|
||||
return make_response('Not Found', 404)
|
||||
|
||||
@registry.errorhandler(403)
|
||||
def fallback_forbidden(e):
|
||||
return make_response('Forbidden', 403)
|
||||
|
||||
@registry.errorhandler(400)
|
||||
def fallback_invalid_request(e):
|
||||
return make_response('Invalid Request', 400)
|
||||
|
||||
|
||||
class SocketReader(object):
|
||||
def __init__(self, fp):
|
||||
self._fp = fp
|
||||
|
|
Reference in a new issue