Skip to content

Welshman Docs / @welshman/lib / tryCatch

Function: tryCatch() ​

tryCatch<T>(f, onError?): undefined | T

Defined in: packages/lib/src/Tools.ts:477

Safely executes function and handles errors

Type Parameters ​

• T

Parameters ​

f ​

() => T

Function to execute

onError? ​

(e) => void

Optional error handler

Returns ​

undefined | T

Function result or undefined if error