happy-rusty
    Preparing search index...

    Function Err

    • Creates a Result<T, E> representing a failed outcome containing an error. This function is used to construct a Result that signifies the operation failed by containing the error E.

      Type Parameters

      • T = never

        The type of the value that the result could potentially contain (not used in this case).

      • E = unknown

        The type of the error to be wrapped in the Err result.

      Parameters

      • error: E

        The error to wrap as an Err result.

      Returns Result<T, E>

      A Result<T, E> that contains the provided error, representing the Err case.

      1.0.0

      const badResult = Err<number, Error>(new Error('Something went wrong'));
      if (badResult.isErr()) {
      console.error(badResult.unwrapErr()); // Outputs: Error: Something went wrong
      }