Skip to main content

Overview

The errAsync function constructs a ResultAsync containing an Err variant with the provided error value.

Signature

E
required
The error value to wrap in a ResultAsync
Returns: ResultAsync<T, E> - A ResultAsync containing the Err value

Usage

Basic usage

Async error handling

Custom error types

When to use

  • Returning an error from an async operation
  • Early returns in validation chains
  • Converting error states to ResultAsync for consistency
Like okAsync, this wraps the error in a resolved Promise. The Promise itself does not reject.

okAsync

Create an Ok variant of ResultAsync

ResultAsync.fromPromise

Handle rejecting Promises