Skip to content

Result

type Result<T, E> =
| {
ok: true;
value: T;
}
| {
error: E;
ok: false;
};

Defined in: packages/engine/src/errors/Result.ts:21

A Rust-style Result<T, E>, the value half of this engine’s error-handling redesign. E defaults to EngineError (this engine’s structured error type) but every combinator here is generic over E, so Result works equally well for a domain that isn’t EngineError-shaped.

This exact shape used to live in errors/UnifiedErrorFramework.ts (kept there as a barrel re-export for backward compatibility), moved here as its own module because it’s genuinely generic (no dependency on EngineError beyond the default type parameter) and because the engine is migrating callers to it incrementally: parsing/VM/package code that expects “a failure is a possibility, not an exception” returns Result<T, EngineError> instead of throwing; two explicit adapters throwIfErr and tryCatch, are the sanctioned way to cross the boundary between Result-based code and still-throw-based code during the migration (and permanently, at the public API boundary. See ExpressionEngine.evaluateExpression()’s documented throw contract).

Type ParameterDefault type
T-
EEngineError