Created
June 14, 2019 14:06
-
-
Save chvonrohr/b10fdfd1c02567361d36780ef8b23d8b to your computer and use it in GitHub Desktop.
try-catch - functional programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function tryCatch({ | |
tryer, | |
catcher | |
}) { | |
return (props) => { | |
try { | |
return tryer(props); | |
} catch (e) { | |
return catcher(props, e.message); | |
} | |
}; | |
} |
Author
chvonrohr
commented
Jun 14, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment