Options
All
  • Public
  • Public/Protected
  • All
Menu

A type representing the result of a failed computation.

This type is not intended to be used or instantiated directly. Instead, Err instances can be created with Result.err and can then be manipulated with any method available on Result.

Please see the Result documentation for more information.

Note:

All Err methods are documented at the Result level.

Type parameters

  • E

    The type of the value contained in this Err instance.

Hierarchy

Index

Methods

flatMap

  • flatMap<T, U>(func: function): Result<U, E>

getErr

getOk

isErr

  • isErr(): boolean

isOk

  • isOk(): boolean

map

  • map<T, U>(func: function): Result<U, E>
  • Type parameters

    • T

    • U

    Parameters

    • func: function
        • (val: T): U
        • Parameters

          • val: T

          Returns U

    Returns Result<U, E>

mapErr

  • mapErr<T, F>(func: function): Result<T, F>
  • Type parameters

    • T

    • F

    Parameters

    • func: function
        • (val: E): F
        • Parameters

          • val: E

          Returns F

    Returns Result<T, F>

match

  • match<T, U, F>(options: ResultMatch<T, E, U, F>): U | F

orElse

  • orElse<T, F>(func: function): Result<T, F>

toString

  • toString(): string

unwrap

  • unwrap<T>(message?: undefined | string): never
  • Type parameters

    • T

    Parameters

    • Optional message: undefined | string

    Returns never

unwrapErr

  • unwrapErr(message: string): E

unwrapOr

  • unwrapOr<T>(other: T): T

unwrapOrElse

  • unwrapOrElse<T>(func: function): T

Static err

  • err<F>(error: F): Result<any, F>
  • Creates an Err with the given value.

    const one = Result.err(1);
    // one.unwrapErr() === 1

    Type parameters

    • F

      The type of value that the new Err will contain.

    Parameters

    • error: F

      The value with which to create the Err instance.

    Returns Result<any, F>

    An Err instance containing value.

Static ok

  • ok<U>(value: U): Result<U, any>
  • Creates an Ok with the given value.

    const one = Result.ok(1);
    // one.unwrap() === 1

    Type parameters

    • U

      The type of value that the new Ok will contain.

    Parameters

    • value: U

      The value with which to create the Ok instance.

    Returns Result<U, any>

    An Ok instance containing value.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc