Evercatch - v0.5.0
    Preparing search index...

    Class Err<E, S>

    Represents a structured error with a label for identification and a source error.

    Type Parameters

    • E extends string = string

      A string literal type for the error label.

    • S = unknown

      The type of the source error.

    Index

    Core

    Constructors

    Properties

    Core

    • Returns a ResultErr containing this error and null.

      Returns ResultErr<E, S>

      A ResultErr.

      const [error, value] = new Err("my_error").result();
      // error is { label: "my_error", source: Error("my_error") }
      // value is null
    • Performs a side effect with the error, then returns the error instance for chaining.

      Parameters

      • fn: (error: this) => void

        The function to execute for the side effect.

      Returns this

      The Err instance.

      const [error, value] = new Err("my_error").tap(e => console.error(e.source)).result();
      

    Constructors

    • Type Parameters

      • E extends string = string
      • S = unknown

      Parameters

      • label: E
      • Optionalsource: S

      Returns Err<E, S>

    Properties

    label: E

    The label identifying the type of error.

    source: S

    The source of the error. Can be any value, but typically an Error object.