Skip to content

Commit

Permalink
Merge pull request #2178 from ckan/2167-remove-extra_msg
Browse files Browse the repository at this point in the history
[#2167] Fix DeprecationWarning: BaseException.message
  • Loading branch information
rossjones committed Dec 31, 2014
2 parents 6024ac3 + d8b5956 commit 8520ca9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ckan/controllers/api.py
Expand Up @@ -209,15 +209,15 @@ def action(self, logic_function, ver=None):
'message': _('Access denied')}
return_dict['success'] = False

if e.message:
return_dict['error']['message'] += ': %s' % e.message
if unicode(e):
return_dict['error']['message'] += u': %s' % e

return self._finish(403, return_dict, content_type='json')
except NotFound, e:
return_dict['error'] = {'__type': 'Not Found Error',
'message': _('Not found')}
if e.message:
return_dict['error']['message'] += ': %s' % e.message
if unicode(e):
return_dict['error']['message'] += u': %s' % e
return_dict['success'] = False
return self._finish(404, return_dict, content_type='json')
except ValidationError, e:
Expand Down Expand Up @@ -289,9 +289,9 @@ def list(self, ver=None, register=None, subregister=None, id=None):
try:
return self._finish_ok(action(context, {'id': id}))
except NotFound, e:
return self._finish_not_found(e.message)
return self._finish_not_found(unicode(e))
except NotAuthorized, e:
return self._finish_not_authz(e.message)
return self._finish_not_authz(unicode(e))

def show(self, ver=None, register=None, subregister=None,
id=None, id2=None):
Expand Down Expand Up @@ -319,9 +319,9 @@ def show(self, ver=None, register=None, subregister=None,
try:
return self._finish_ok(action(context, data_dict))
except NotFound, e:
return self._finish_not_found(e.message)
return self._finish_not_found(unicode(e))
except NotAuthorized, e:
return self._finish_not_authz(e.message)
return self._finish_not_authz(unicode(e))

def _represent_package(self, package):
return package.as_dict(ref_package_by=self.ref_package_by,
Expand Down Expand Up @@ -367,9 +367,9 @@ def create(self, ver=None, register=None, subregister=None,
return self._finish_ok(response_data,
resource_location=location)
except NotAuthorized, e:
return self._finish_not_authz(e.message)
return self._finish_not_authz(unicode(e))
except NotFound, e:
return self._finish_not_found(e.message)
return self._finish_not_found(unicode(e))
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
Expand Down Expand Up @@ -422,9 +422,9 @@ def update(self, ver=None, register=None, subregister=None,
response_data = action(context, data_dict)
return self._finish_ok(response_data)
except NotAuthorized, e:
return self._finish_not_authz(e.message)
return self._finish_not_authz(unicode(e))
except NotFound, e:
return self._finish_not_found(e.message)
return self._finish_not_found(unicode(e))
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
Expand Down Expand Up @@ -469,9 +469,9 @@ def delete(self, ver=None, register=None, subregister=None,
response_data = action(context, data_dict)
return self._finish_ok(response_data)
except NotAuthorized, e:
return self._finish_not_authz(e.message)
return self._finish_not_authz(unicode(e))
except NotFound, e:
return self._finish_not_found(e.message)
return self._finish_not_found(unicode(e))
except ValidationError, e:
# CS: nasty_string ignore
log.error('Validation error: %r' % str(e.error_dict))
Expand Down

0 comments on commit 8520ca9

Please sign in to comment.