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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
T |
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
fn | () => T | undefined |
normalize | (e) => EngineError | normalizeUnknownError |
Returns
Section titled “Returns”Result<T, EngineError>