Skip to content

Instantly share code, notes, and snippets.

@gilligan
Created December 9, 2015 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gilligan/66a1ac0431a0e77fdaae to your computer and use it in GitHub Desktop.
Save gilligan/66a1ac0431a0e77fdaae to your computer and use it in GitHub Desktop.
wrap function that might throw so it returns an Either
export const wrapEither = (f) => {
return R.curryN(f.length, () => {
try {
return Either.Right(f.apply(this, arguments));
} catch (err) {
return Either.Left(err);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment