mirror of https://github.com/zulip/zulip.git
rows.js: Add error handling to rows.id().
We get random blueslip errors from code that calls rows.id(), and the error messages are rarely helpful.
This commit is contained in:
parent
184f51ee0c
commit
531cafb501
|
@ -53,6 +53,8 @@ run_test('youtube', () => {
|
|||
const link = $.create('link-stub');
|
||||
const msg = $.create('msg-stub');
|
||||
|
||||
msg.attr("zid", "4321");
|
||||
|
||||
$(img).attr('src', href);
|
||||
|
||||
$(img).closest = (sel) => {
|
||||
|
|
|
@ -42,7 +42,24 @@ exports.last_visible = function () {
|
|||
};
|
||||
|
||||
exports.id = function (message_row) {
|
||||
return parseFloat(message_row.attr('zid'));
|
||||
/*
|
||||
For blueslip errors, don't return early, since
|
||||
we may have some code now that actually relies
|
||||
on the NaN behavior here. We can try to clean
|
||||
that up in the future, but we mainly just want
|
||||
more data now.
|
||||
*/
|
||||
if (message_row.length !== 1) {
|
||||
blueslip.error("Caller should pass in a single row.");
|
||||
}
|
||||
|
||||
const zid = message_row.attr('zid');
|
||||
|
||||
if (zid === undefined) {
|
||||
blueslip.error("Calling code passed rows.id a row with no zid attr.");
|
||||
}
|
||||
|
||||
return parseFloat(zid);
|
||||
};
|
||||
|
||||
const valid_table_names = {
|
||||
|
|
Loading…
Reference in New Issue