@metreeca/core - v0.9.7
    Preparing search index...

    Function guard

    • Wraps an asynchronous function with error handling and logging.

      Catches errors thrown or rejected by the function, logs them via log using the function's name, and returns undefined instead of propagating the error.

      Type Parameters

      • T extends unknown[]

        The tuple type of function arguments

      • R

        The return type of the function

      Parameters

      • f: (...args: T) => Promise<R>

        Async function to wrap with error handling

      Returns (...args: T) => Promise<R | undefined>

      Wrapped function that returns a promise resolving to the original result or undefined on error

    • Wraps a synchronous function with error handling and logging.

      Catches errors thrown by the function, logs them via log using the function's name, and returns undefined instead of propagating the error.

      Type Parameters

      • T extends unknown[]

        The tuple type of function arguments

      • R

        The return type of the function

      Parameters

      • f: (...args: T) => R

        Function to wrap with error handling

      Returns (...args: T) => R | undefined

      Wrapped function that returns the original result or undefined on error