Add back error_message and error_type for backwards-compatibility

This commit is contained in:
Evan Cordell 2016-04-13 09:02:24 -04:00
parent 7b44beb1fd
commit e1b3312495
2 changed files with 35 additions and 25 deletions

View file

@ -197,6 +197,14 @@ def swagger_route_data(include_internal=False, compact=False):
'title': { 'title': {
'type': 'string', 'type': 'string',
'description': 'Unique error code to identify the type of error.' 'description': 'Unique error code to identify the type of error.'
},
'error_message': {
'type': 'string',
'description': 'Deprecated; alias for detail'
},
'error_type': {
'type': 'string',
'description': 'Deprecated; alias for detail'
} }
}, },
'required': [ 'required': [
@ -224,7 +232,7 @@ def swagger_route_data(include_internal=False, compact=False):
}, },
} }
for status, body in responses.items(): for _, body in responses.items():
body['schema'] = {'$ref': '#/definitions/ApiError'} body['schema'] = {'$ref': '#/definitions/ApiError'}
if method_name == 'DELETE': if method_name == 'DELETE':

View file

@ -67,7 +67,9 @@ class ApiException(Exception):
if self.error_description is not None: if self.error_description is not None:
rv['detail'] = self.error_description rv['detail'] = self.error_description
rv['error_message'] = self.error_description # TODO: deprecate
rv['error_type'] = self.error_type.value # TODO: deprecate
rv['title'] = self.error_type.value rv['title'] = self.error_type.value
rv['type'] = url_for('error', error_type=self.error_type.value, _external=True) rv['type'] = url_for('error', error_type=self.error_type.value, _external=True)
rv['status'] = self.status_code rv['status'] = self.status_code