Evercatch - v0.10.0
    Preparing search index...

    Variable errReadonly

    err: { (): ResultErr<Error>; <E extends unknown>(error: E): ResultErr<E> }

    See err.

    Type declaration

      • (): ResultErr<Error>
      • Creates an error result with a new Error.

        Returns ResultErr<Error>

        A ResultErr containing a new Error.

        const [error, value] = err(); // [Error, null]
        
      • <E extends unknown>(error: E): ResultErr<E>
      • Creates an error result with the given error.

        The error cannot be nullish, since null in the error slot means "this result is ok". Nullish arguments are rejected at compile time, and replaced with a new Error at runtime as a last resort. See NotNullish.

        Any other value is passed through as is, including falsy ones.

        Type Parameters

        • E extends unknown

          The type of the error. Cannot be nullish.

        Parameters

        • error: E

          The error to wrap in an error result.

        Returns ResultErr<E>

        A ResultErr containing the error.

        const [error, value] = err(new Error("Oops")); // [Error: Oops, null]
        
        const [error, value] = err("Oops"); // ["Oops", null]
        
        const [error, value] = err(null); // Type error: null means "no error"