summaryrefslogtreecommitdiff
path: root/web-ui/app
diff options
context:
space:
mode:
authorAlexandre Pretto Nunes <anunes@thoughtworks.com>2014-10-15 16:41:29 -0300
committerAlexandre Pretto Nunes <anunes@thoughtworks.com>2014-10-16 16:21:43 -0300
commit1b7ebf85c27a6bdf11d6478f208650d969b4b9a1 (patch)
tree7024814c6a4373124e17f38b45c84878f0279c41 /web-ui/app
parent5885be6bac040462fca139092d3ba3e66fd7ac25 (diff)
#92 Handle exceptions from the service in the ui
Diffstat (limited to 'web-ui/app')
-rw-r--r--web-ui/app/js/mail_view/data/mail_sender.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/web-ui/app/js/mail_view/data/mail_sender.js b/web-ui/app/js/mail_view/data/mail_sender.js
index 6d572e77..7ada0d16 100644
--- a/web-ui/app/js/mail_view/data/mail_sender.js
+++ b/web-ui/app/js/mail_view/data/mail_sender.js
@@ -39,9 +39,19 @@ define(
};
}
- function failure(on) {
+ function failure(on, context) {
return function(xhr, status, error) {
- on.trigger(events.ui.userAlerts.displayMessage, {message: 'Ops! something went wrong, try again later.'});
+ var contextMessage = '';
+
+ if (context) {
+ contextMessage = context + ': ';
+ }
+
+ if (xhr.responseJSON.message) {
+ on.trigger(document, events.ui.userAlerts.displayMessage, {message: contextMessage + xhr.responseJSON.message});
+ } else {
+ on.trigger(document, events.ui.userAlerts.displayMessage, {message: 'Ops! something went wrong, try again later.'});
+ }
};
}
@@ -56,7 +66,7 @@ define(
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data)
}).done(successSendMail(this))
- .fail(failure(this));
+ .fail(failure(this, 'Error sending mail'));
};
this.saveMail = function(mail) {