Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

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>