From 342551ca0da9018b469bf607404cefb9608f95e9 Mon Sep 17 00:00:00 2001 From: Horizontal42 <75383519+Horizontal42@users.noreply.github.com> Date: Wed, 12 Aug 2026 22:01:52 +0300 Subject: [PATCH] [Code Health] Replace generic Error with specific EvalError in tests What: Replaced `throw new Error("test error")` with `throw new EvalError("test error")` in the `sequence error recovery` test case within `src/engine/engine.test.ts`. Why: `EvalError` is the standard domain error used by the evaluation engine. Throwing a generic `Error` triggers a console warning in the error handling code (which treats it as an unexpected bug), whereas `EvalError` is correctly handled silently as expected evaluation failure, improving the clarity of what kind of error is being tested. Verification: Ran `npm run test src/engine/engine.test.ts` and the full test suite via `npm run test`, which all completed successfully. Result: More accurate test setup and adherence to the evaluation engine's specific error handling abstractions. --- src/engine/engine.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/engine.test.ts b/src/engine/engine.test.ts index febef3a..e8d8454 100644 --- a/src/engine/engine.test.ts +++ b/src/engine/engine.test.ts @@ -218,7 +218,7 @@ describe("numeral systems", () => { describe("variables and document context", () => { it("sequence error recovery", () => { eng.addFunction({ id: "throw_err", phrases: "throw_err" }, () => { - throw new Error("test error"); + throw new EvalError("test error"); }); expect(calc("throw_err(1) 2 hours")).toBe("2 h"); });