Wraps callback to try/catch block
const result = tryCatch(() => fetch('http://example.com'))if (value instanceof Error) { console.log(value.message)}const parsedOrUndefined = tryCatch(() => JSON.parse(jsonString), undefined) Copy
const result = tryCatch(() => fetch('http://example.com'))if (value instanceof Error) { console.log(value.message)}const parsedOrUndefined = tryCatch(() => JSON.parse(jsonString), undefined)
Wraps callback to try/catch block