tryCatch
import { tryCatch } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/sync_either.ts";Wrap a function that can throw in a try/catch block, returning a SyncEither.
@example
import { tryCatch } from "./sync_either.ts";
const riskyFunction = () => {
if (Math.random() > 0.5) throw new Error("Random failure");
return "Success";
};
const safe = tryCatch(riskyFunction, (e) => `Error: ${e}`);
const result = safe(); // Either Right("Success") or Left("Error: ...")
function tryCatch<A = never, B = never>(fa: () => A, onError: (error: unknown) => B): SyncEither<B, A>;