diff options
author | Alexandre Pretto Nunes <anunes@thoughtworks.com> | 2014-10-14 11:14:59 -0300 |
---|---|---|
committer | Alexandre Pretto Nunes <anunes@thoughtworks.com> | 2014-10-16 16:18:50 -0300 |
commit | 5885be6bac040462fca139092d3ba3e66fd7ac25 (patch) | |
tree | bffc2da88d9161f6022fd7cc5acc00afec350263 /service/pixelated | |
parent | 19f89c970b214d2b131cbc4124b1630b0f330efa (diff) |
Better handle information on exceptions. #92
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/controllers/mails_controller.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/service/pixelated/controllers/mails_controller.py b/service/pixelated/controllers/mails_controller.py index d1de4973..491f325a 100644 --- a/service/pixelated/controllers/mails_controller.py +++ b/service/pixelated/controllers/mails_controller.py @@ -87,7 +87,7 @@ class MailsController: return respond_json(_mail.as_dict()) except Exception as error: - return respond_json({'message': '\n'.join(list(error.args))}, status_code=500) + return respond_json({'message': self._format_exception(error)}, status_code=422) def mail_tags(self, mail_id): new_tags = map(lambda tag: tag.lower(), request.get_json()['newtags']) @@ -110,3 +110,7 @@ class MailsController: self._search_engine.index_mail(self._mail_service.mail(ident)) return respond_json({'ident': ident}) + + def _format_exception(self, exception): + exception_info = map(str, list(exception.args)) + return '\n'.join(exception_info) |