Switch make_json_error back to being a function
This was originally a function, and then I changed it to a dict because Flask complained. Now Flask complains that is a dict, so change it back to being a function. Change-Id: Iec30b4cf5023be711ac070def00b77e91978d992
This commit is contained in:
parent
b23abe2f96
commit
9aab4b5e47
|
@ -43,19 +43,16 @@ def build_app():
|
|||
app.register_blueprint(api_v10.rest, url_prefix='/v1.1')
|
||||
app.register_blueprint(api_v11.rest, url_prefix='/v1.1')
|
||||
|
||||
class _JSONErrorHandler(dict):
|
||||
def __getitem__(self, ex):
|
||||
status_code = (ex.code
|
||||
if isinstance(ex, werkzeug_exceptions.HTTPException)
|
||||
else 500)
|
||||
description = (ex.description
|
||||
if isinstance(ex, werkzeug_exceptions.HTTPException)
|
||||
else str(ex))
|
||||
return api_utils.render({'error': status_code,
|
||||
'error_message': description},
|
||||
status=status_code)
|
||||
|
||||
make_json_error = _JSONErrorHandler()
|
||||
def make_json_error(ex):
|
||||
status_code = (ex.code
|
||||
if isinstance(ex, werkzeug_exceptions.HTTPException)
|
||||
else 500)
|
||||
description = (ex.description
|
||||
if isinstance(ex, werkzeug_exceptions.HTTPException)
|
||||
else str(ex))
|
||||
return api_utils.render({'error': status_code,
|
||||
'error_message': description},
|
||||
status=status_code)
|
||||
|
||||
for code in six.iterkeys(werkzeug_exceptions.default_exceptions):
|
||||
app.register_error_handler(code, make_json_error)
|
||||
|
|
Loading…
Reference in New Issue