Skip to content

Commit

Permalink
Continue on parseJSON error (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmahmalat committed Mar 12, 2024
1 parent 8a8b9f0 commit 605c483
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ function apiCall(method, path, params, cb) {
return cb({ error: "Query timeout after " + timeout + "s" });
}

cb(jQuery.parseJSON(xhr.responseText));
var responseText;
try {
responseText = jQuery.parseJSON(xhr.responseText);
}
catch {
responseText = { error: "Failed to parse the JSON response." };
}
cb(responseText);
}
});
}
Expand Down

0 comments on commit 605c483

Please sign in to comment.