MDL-55569 messages: Throw an error when the message fails to send
This shows an alert to the user to let them know something went wrong. If debugging is 0 - the alert does not contain all the debugging stuff and looks OK.
This commit is contained in:
committed by
Mark Nelson
parent
14968ca9ac
commit
eaabf0934a
@@ -254,7 +254,14 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
|
||||
}]);
|
||||
|
||||
// Update the DOM when we get some data back.
|
||||
return promises[0].then(function() {
|
||||
return promises[0].then(function(response) {
|
||||
if (response.length < 0) {
|
||||
// Even errors should return valid data.
|
||||
throw new Error('Invalid response');
|
||||
}
|
||||
if (response[0].errormessage) {
|
||||
throw new Error(response[0].errormessage);
|
||||
}
|
||||
// Fire an event to say the message was sent.
|
||||
this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESENT, [this._getUserId(), text]);
|
||||
// Update the messaging area.
|
||||
|
||||
Reference in New Issue
Block a user