fix: correctly surface unexpected evaluation errors

Previously, all errors in evaluation were completely swallowed except for
`XRefError`. This caused unexpected errors (e.g., BigInt conversion errors
or extension bugs) to result in a silently dead sheet.

This updates the `evaluateDocument` catch block to:
1. Continue surfacing `XRefError` (no console warning).
2. Continue silently ignoring expected `EvalError` instances.
3. Surface all other unexpected errors to the user via `lineError` and log
   them to the console, making debugging easier without crashing the application.

Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
google-labs-jules[bot] 2026-08-09 10:39:25 +00:00
parent d0c1865e31
commit 9038f87bea

View file

@ -134,11 +134,18 @@ export class SumEngine {
}; };
try { try {
value = evaluate(parsed.expr, ctx); value = evaluate(parsed.expr, ctx);
// a line without a result beats a dead sheet — swallow everything, // a line without a result beats a dead sheet.
// including extension bugs and BigInt conversion errors // surface unexpected bugs so the user knows why it failed
} catch (e) { } catch (e) {
if (e instanceof XRefError) {
lineError = e.message;
} else if (e instanceof EvalError) {
// Expected evaluation failure; remain silent
} else {
// Surface unexpected bugs/BigInt errors and log them
lineError = e instanceof Error ? e.message : String(e); lineError = e instanceof Error ? e.message : String(e);
if (!(e instanceof EvalError)) console.warn("evaluate failed:", e); console.warn("evaluate failed:", e);
}
value = null; value = null;
} }
if (value?.kind === "quantity" && !value.value.isFinite()) value = null; if (value?.kind === "quantity" && !value.value.isFinite()) value = null;