method AsyncResult.prototype.orElse
AsyncResult.prototype.orElse<U, F extends BaseError>(fn: (error: E) => Result<U, F> | AsyncResult<U, F> | Promise<Result<U, F>>): AsyncResult<T | U, F>

Returns this result if Ok, otherwise computes a fallback from the error.

Type Parameters

F extends BaseError

Parameters

fn: (error: E) => Result<U, F> | AsyncResult<U, F> | Promise<Result<U, F>>

Function to compute a fallback Result from the error

Return Type

AsyncResult of this or the computed fallback

Usage

import { AsyncResult } from "result/mod.ts";