Function tryCatchWrapAsync

  • Wraps an asynchronous function, catches all sync and async errors and passes them to the onError callback instead of throwing. All promises are resolved. If there was an error, they are resolved with 'undefined'.

    Type Parameters

    • R

    • T extends ((...args) => Promise<void | R>)

    Parameters

    • func: T

      The function to wrap.

    • Optional onError: ((error) => void)
        • (error): void
        • Parameters

          • error: Error

          Returns void

    Returns ((this, ...args) => Promise<void | R>)

    A new function that wraps the original function with error handling.

      • (this, ...args): Promise<void | R>
      • Parameters

        • this: unknown
        • Rest ...args: Parameters<T>

        Returns Promise<void | R>

Generated using TypeDoc