# tryCatch | Welshman Docs
Documentation for Welshman Docs

# Function tryCatch

Safely executes function and handles errors

- tryCatch< T >(f: () => T , onError?: (e: Error) => void): undefined | T

- #### Type Parameters

  - T

  #### Parameters

  - f: () => T

    Function to execute

  - `Optional` onError: (e: Error) => void

    Optional error handler

  #### Returns undefined | T

  Function result or undefined if error

  - Defined in packages/lib/src/Tools.ts:411