Skip to main content

Try

import { Failure, Result, Success } from '@rtorcato/js-common/try'

Exports

NameSummary
FailureError branch of a Result — carries a null value and an error of type E.
ResultGo-style discriminated union representing either a Success<T> or a Failure<E>, for async code that prefers explicit error returns over thrown exceptions.
SuccessSuccessful branch of a Result — carries the value and a null error.
isSuccessType guard that narrows a Result to its Success branch when the error is null.
tryCatchRun an async function and capture any thrown error into a Result, eliminating try/catch at the call site.