diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-11-11 12:40:35 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-11-11 12:40:35 -0300 |
commit | 352163eefb9c1e1281b618e357f7673b07a49eb8 (patch) | |
tree | df048c95f5b3427ee612604c00a4cc6f399a907c /service/pixelated/resources | |
parent | 67983902a6a35c5c6de531ba10214c5ef4ac33c9 (diff) |
unhandled errors were not being logged and generated no response back
Diffstat (limited to 'service/pixelated/resources')
-rw-r--r-- | service/pixelated/resources/mails_resource.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py index 93a19a9b..499610de 100644 --- a/service/pixelated/resources/mails_resource.py +++ b/service/pixelated/resources/mails_resource.py @@ -160,21 +160,23 @@ class MailsResource(Resource): _mail = InputMail.from_dict(content_dict) draft_id = content_dict.get('ident') + def onError(error): + err(error, 'error saving draft') + respond_json_deferred("", request, status_code=422) + def defer_response(deferred): deferred.addCallback(lambda pixelated_mail: respond_json_deferred({'ident': pixelated_mail.ident}, request)) + deferred.addErrback(onError) if draft_id: deferred_check = self._mail_service.mail_exists(draft_id) - def handleDuplicatedDraftException(error): - respond_json_deferred("", request, status_code=422) - def return422otherwise(mail_exists): if not mail_exists: respond_json_deferred("", request, status_code=422) else: new_draft = self._draft_service.update_draft(draft_id, _mail) - new_draft.addErrback(handleDuplicatedDraftException) + new_draft.addErrback(onError) defer_response(new_draft) deferred_check.addCallback(return422otherwise) |