Skip to content

tryCatch

function tryCatch<T>(fn, normalize?): Result<T, EngineError>;

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

Cross from throw-space into Result-space, runs fn, converting any thrown value into a Result via normalize (defaults to normalizeUnknownError). The inverse of throwIfErr; the pairing that lets Result-based and throw-based code interoperate during an incremental migration instead of requiring a single flag-day rewrite.

Type Parameter
T
ParameterTypeDefault value
fn() => Tundefined
normalize(e) => EngineErrornormalizeUnknownError

Result<T, EngineError>