Evercatch - v0.5.0
    Preparing search index...

    Function err

    • Creates a ResultErr. It can be called with a label and source, or with an existing Err object.

      Type Parameters

      • E extends string = string

        A string literal type for the error label.

      • S = Error

        The type of the source error.

      Parameters

      • label: E

        The error label.

      • Optionalsource: S

        The source of the error. If not provided, a new Error with the label as the message will be created.

      Returns ResultErr<E, S>

      A ResultErr.

      const [error, value] = err("not_found");
      // error is { label: "not_found", source: Error("not_found") }
      // value is null
      const [error, value] = err("not_found", new Error("Resource not found"));
      // error is { label: "not_found", source: Error("Resource not found") }
      // value is null