Evercatch - v0.3.1
    Preparing search index...

    Class Err<E>

    Extends the built-in Error class with a label and an optional source.

    Type Parameters

    • E extends string = string

      The type of the error label, constrained to string

    Hierarchy

    • Error
      • Err
    Index

    Constructors

    • Type Parameters

      • E extends string = string

      Parameters

      • label: E
      • Optionalmessage: string
      • Optionalsource: unknown

      Returns Err<E>

    Methods

    • Create .stack property on a target object

      Parameters

      • targetObject: object
      • OptionalconstructorOpt: Function

      Returns void

    • Creates an Err instance from an unknown value.

      Type Parameters

      • E extends string = string

      Parameters

      • source: unknown

        The error value to convert

      • label: E

        The label to identify the error type

      Returns Err<E>

      An Err instance

      const error = new Error("The requested resource was not found");
      const err = Err.from(error, "NOT_FOUND");
    • Creates a ResultErr from an unknown value.

      Type Parameters

      • E extends string = string

      Parameters

      • source: unknown

        The error value to convert

      • label: E

        The label to identify the error type

      Returns ResultErr<E>

      A ResultErr

      const error = new Error("The requested resource was not found");
      const result = Err.resultFrom(error, "NOT_FOUND");
      // result: [Err<"NOT_FOUND">, null]

    Properties

    cause?: unknown
    label: E

    The label identifying the type of error.

    message: string
    name: string
    source?: unknown

    The source of the error, if applicable.

    stack?: string
    prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

    Optional override for formatting stack traces

    stackTraceLimit: number