Skip to content

Instantly share code, notes, and snippets.

@nadeesha
Created May 19, 2019 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nadeesha/3013e1e9fcb0cd84023342395075e1a5 to your computer and use it in GitHub Desktop.
Save nadeesha/3013e1e9fcb0cd84023342395075e1a5 to your computer and use it in GitHub Desktop.
export function tryCatch<Props, Result>({
tryer,
catcher
}: {
tryer: (props: Props) => Result;
catcher: (props: Props, message: string) => Result;
}) {
return (props: Props) => {
try {
return tryer(props);
} catch (e) {
return catcher(props, e.message);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment