Function trycatch

A higher-order function that wraps the provided function with a try-catch block. It catches any errors that occur during the execution of the function and handles them according to the specified configuration.

  • Type Parameters

    • T extends ((...args: A) => any)

      The type of the function being wrapped

    • A extends any[]

      An array of arguments that the function accepts

    • V extends unknown

      The type of the value returned by the function

    Parameters

    • run: T

      The function to be wrapped

    • config: Partial<IConfig> = {}

      The configuration object

    Returns ((...args: A) => null | ReturnType<T>)

    • The wrapped function that handles errors and returns the result or the default value
      • (...args): null | ReturnType<T>
      • Parameters

        • Rest...args: A

        Returns null | ReturnType<T>