Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ui_report: Use numerical check for request status code.

Priyank Patel5ae523891baf
diff --git a/static/js/ui_report.js b/static/js/ui_report.js
index b2bfa20a0a2..2cd84a0c03f 100644
--- a/static/js/ui_report.js
+++ b/static/js/ui_report.js
@@ -28,7 +28,7 @@ export function message(response_html, status_box, cls = "alert", remove_after =
}
export function error(response_html, xhr, status_box, remove_after) {
- if (xhr && xhr.status.toString().charAt(0) === "4") {
+ if (xhr && xhr.status >= 400 && xhr.status < 500) {
// Only display the error response for 4XX, where we've crafted
// a nice response.
const server_response_html = _.escape(JSON.parse(xhr.responseText).msg);
@@ -60,7 +60,7 @@ export function generic_embed_error(error_html) {
}
export function generic_row_button_error(xhr, btn) {
- if (xhr.status.toString().charAt(0) === "4") {
+ if (xhr.status >= 400 && xhr.status < 500) {
btn.closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg),
);