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:
Steve Howell 2020-02-21 16:29:23 +00:00 committed by Tim Abbott
parent 184f51ee0c
commit 531cafb501
2 changed files with 20 additions and 1 deletions

View File

@ -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) => {

View File

@ -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 = {