method Task.prototype.recoverWhen
Task.prototype.recoverWhen<
E2 extends E,
U,
>
(
guard: (error: E) => error is E2,
fn: (error: E2) => Promisable<U>,
): Task<T | U, Exclude<E, E2>>

Recovers from specific error types by mapping them to a successful value.

Type Parameters

E2 extends E

Parameters

guard: (error: E) => error is E2
fn: (error: E2) => Promisable<U>

Return Type

Task<T | U, Exclude<E, E2>>

Usage

import { Task } from ".";