mirror of https://github.com/zulip/zulip.git
Move xhr_error_message() into channel.js
(imported from commit c68c2d475b5673a3dd5f68c75624dfcfe56728ca)
This commit is contained in:
parent
0e129614cf
commit
3889edd824
|
@ -110,6 +110,15 @@ exports.patch = function (options) {
|
||||||
return exports.post(options, options.idempotent);
|
return exports.post(options, options.idempotent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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;
|
return exports;
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
|
@ -373,7 +373,7 @@ function send_message_ajax(request, success, error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var response = util.xhr_error_message("Error sending message", xhr);
|
var response = channel.xhr_error_message("Error sending message", xhr);
|
||||||
error(response);
|
error(response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,7 +62,7 @@ exports.save = function (row) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (xhr, error_type, xhn) {
|
error: function (xhr, error_type, xhn) {
|
||||||
var message = util.xhr_error_message("Error saving edit", xhr);
|
var message = channel.xhr_error_message("Error saving edit", xhr);
|
||||||
row.find(".edit_error").text(message).show();
|
row.find(".edit_error").text(message).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -204,15 +204,6 @@ exports.array_compare = function util_array_compare(a, b) {
|
||||||
return true;
|
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Represents a value that is expensive to compute and should be
|
/* Represents a value that is expensive to compute and should be
|
||||||
* computed on demand and then cached. The value can be forcefully
|
* computed on demand and then cached. The value can be forcefully
|
||||||
* recalculated on the next call to get() by calling reset().
|
* recalculated on the next call to get() by calling reset().
|
||||||
|
|
Loading…
Reference in New Issue