Fix: Surface evaluation failures to avoid hiding bugs

Modifies `src/engine/index.ts` to surface unhandled evaluation errors.
Previously, generic exceptions were completely silenced, masking bugs
or `BigInt` conversion errors. Now, `EvalError` exceptions correctly populate
the `lineError` so they are surfaced in the UI without crashing the sheet.
Other generic runtime errors are also captured and output to the UI and console.
`XRefError` exceptions are preserved and behave identically as before.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-07-28 23:48:34 +00:00
parent f5b1fc038b
commit 1872c4b159

View file

@ -138,7 +138,11 @@ export class SumEngine {
// including extension bugs and BigInt conversion errors // including extension bugs and BigInt conversion errors
} catch (e) { } catch (e) {
if (e instanceof XRefError) lineError = e.message; if (e instanceof XRefError) lineError = e.message;
else if (!(e instanceof EvalError)) console.warn("evaluate failed:", e); else if (e instanceof EvalError) lineError = e.message;
else {
console.warn("evaluate failed:", e);
lineError = e instanceof Error ? e.message : String(e);
}
value = null; value = null;
} }
if (value?.kind === "quantity" && !value.value.isFinite()) value = null; if (value?.kind === "quantity" && !value.value.isFinite()) value = null;