Skip to main content

tryToError

Callable


  • Convert the Try to a its value, where Success is converted to the value, and Failure is thrown`.

    Example

    tryToError("foobar")
    // => "foobar"

    tryToError(new Error("foobar"))
    // => throw Error("foobar")

    @param x - The Try to transform.


    Type parameters

    • T: unknown

      The value type.

    Parameters

    • x: T

    Returns T extends Failure ? never : Success<T>