mirror of https://github.com/zulip/zulip.git
rows: Throw exception instead of returning NaN.
We don't expect this to happen, and we don't want to try to maintain the difficult task of gracefully handling errors that we don't expect to happen anyways. This will also make the conversion to typescript easier.
This commit is contained in:
parent
17bc9af106
commit
e3e0125092
|
@ -80,22 +80,14 @@ export function id($message_row) {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
/*
|
||||
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.");
|
||||
throw new 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.");
|
||||
throw new Error("Calling code passed rows.id a row with no zid attr.");
|
||||
}
|
||||
|
||||
return Number.parseFloat(zid);
|
||||
|
|
Loading…
Reference in New Issue