method AsyncResult.prototype.mapErr
AsyncResult.prototype.mapErr<F extends BaseError>(fn: (error: E) => F): AsyncResult<T, F>

Transforms the Err value using a mapper function, leaving Ok untouched.

Examples

Example 1

const result = fetchUser("123")
  .mapErr(e => new NetworkError({ cause: e }));

Type Parameters

F extends BaseError

The type of the transformed error

Parameters

fn: (error: E) => F

Function to transform the Err value

Return Type

A new AsyncResult with the transformed error

Usage

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