Show server errors in the message edit form.

Refactor common code from compose into a util function.

Trac #1455, #1448

(imported from commit 6fb691ac952b833655584b05f6caedaefe41c1a0)
This commit is contained in:
Kevin Mehall
2013-07-11 17:42:44 -04:00
parent 77aeee118b
commit 7f7843020d
4 changed files with 16 additions and 6 deletions

View File

@@ -379,12 +379,7 @@ function send_message() {
reload.initiate({immediate: true, send_after_reload: true});
return;
}
var response = "Error sending message";
if (xhr.status.toString().charAt(0) === "4") {
// Only display the error response for 4XX, where we've crafted
// a nice response.
response += ": " + $.parseJSON(xhr.responseText).msg;
}
var response = util.xhr_error_message("Error sending message", xhr);
compose_error(response, $('#new_message_content'));
}
});