tryCatchSync
function tryCatchSync<T, E>(fn): Result<T, E>;Defined in: try-catch.ts:108
Convert a sync function call into a tuple result: [data, error].
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T |
- |
E |
Error |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fn |
() => T |
Returns
Section titled “Returns”Result<T, E>
Example
Section titled “Example”const [value, error] = tryCatch(() => JSON.parse('{"ok":true}')); // same behavior