mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +03:00
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:
parent
d0c1865e31
commit
9038f87bea
1 changed files with 11 additions and 4 deletions
|
|
@ -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) {
|
||||||
lineError = e instanceof Error ? e.message : String(e);
|
if (e instanceof XRefError) {
|
||||||
if (!(e instanceof EvalError)) console.warn("evaluate failed:", e);
|
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);
|
||||||
|
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;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue