/** * Constructs a new `Either` from a function that might throw. * * @tsplus static Either.Ops tryCatch */ export function tryCatch( f: LazyArg, onError: (e: unknown) => E ): Either { try { return Either.right(f()) } catch (e) { return Either.left(onError(e)) } }