Function tryCatchingAsync

  • Execute an async block of code, catching any errors of the specified types and returning them as Err.

    If no errors are specified, the block will be executed as if it were passed to tryingAsync.

    Type Parameters

    • T
    • E extends Error

    Parameters

    • errors: ErrorClass[]

      The expected error types to catch from the block.

    • block: Promise<T> | (() => Promise<T>)

      The block of code to execute.

    Returns Promise<Result<T, E>>

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