Function trying

  • Execute a block of code, catching any errors and returning them as Err.

    Type Parameters

    • T
    • E extends Error

    Parameters

    • block: (() => T)

      The block of code to execute.

        • (): T
        • Returns T

    Returns Result<T, E>

    The result of the block wrapped in an Ok, or an Err containing any error thrown by the block.