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

@@ -253,5 +253,15 @@ exports.array_compare = function util_array_compare(a, b) {
return true;
};
exports.xhr_error_message = function (message, xhr) {
if (xhr.status.toString().charAt(0) === "4") {
// Only display the error response for 4XX, where we've crafted
// a nice response.
message += ": " + $.parseJSON(xhr.responseText).msg;
}
return message;
};
return exports;
}());