Interface Err<T, E>

An Err instance is the failure variant instance of the Result type, representing a failure outcome from an operation which may fail. For a full discussion, see the module docs.

interface Err<T, E> {
    error: E;
    isErr: true;
    isOk: false;
    variant: "Err";
    and<U>(mAnd: Result<U, E>): Result<U, E>;
    andThen<U>(andThenFn: (t: T) => Result<U, E>): Result<U, E>;
    ap<A, B>(this: Result<(a: A) => B, E>, r: Result<A, E>): Result<B, E>;
    cast<U>(): Result<U, E>;
    equals(comparison: Result<T, E>): boolean;
    map<U>(mapFn: (t: T) => U): Result<U, E>;
    mapErr<F>(mapErrFn: (e: E) => F): Result<T, F>;
    mapOr<U>(orU: U, mapFn: (t: T) => U): U;
    mapOrElse<U>(orElseFn: (err: E) => U, mapFn: (t: T) => U): U;
    match<U>(matcher: Matcher<T, E, U>): U;
    or<F>(orResult: Result<T, F>): Result<T, F>;
    orElse<F>(orElseFn: (err: E) => Result<T, F>): Result<T, F>;
    toJSON(): ResultJSON<T, E>;
    toString(): string;
    unwrapOr<U = T>(defaultValue: U): T | U;
    unwrapOrElse<U>(elseFn: (error: E) => U): T | U;
}

Type Parameters

  • T

    The type which would be wrapped in an Ok variant of Result.

  • E

    The type wrapped in this Err variant of Result.

Hierarchy

  • Omit<ResultImpl<T, E>, "value" | "cast">
    • Err

Properties

error: E

The wrapped error value.

isErr: true

Is the Result an Err?

isOk: false

Is the Result an Ok?

variant: "Err"

Err is always Variant.Err.

Methods

  • Method variant for mapOr

    Type Parameters

    • U

    Parameters

    • orU: U
    • mapFn: (t: T) => U

    Returns U

  • Method variant for mapOrElse

    Type Parameters

    • U

    Parameters

    • orElseFn: (err: E) => U
    • mapFn: (t: T) => U

    Returns U

  • Method variant for toString

    Returns string

  • Method variant for unwrapOr

    Type Parameters

    • U = T

    Parameters

    • defaultValue: U

    Returns T | U

  • Method variant for unwrapOrElse

    Type Parameters

    • U

    Parameters

    • elseFn: (error: E) => U

    Returns T | U