Skip to content

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 Parameter Default type
T -
E Error
Parameter Type
fn () => T

Result<T, E>

const [value, error] = tryCatch(() => JSON.parse('{"ok":true}')); // same behavior