Safely executes function and handles errors

  • Type Parameters

    • T

    Parameters

    • f: () => T

      Function to execute

    • OptionalonError: (e: Error) => void

      Optional error handler

    Returns undefined | T

    Function result or undefined if error