Created
December 23, 2017 07:14
-
-
Save mornir/7b4eff05058617815f3363f1ee6c1c54 to your computer and use it in GitHub Desktop.
Async Await Error Handling
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
function catchErrors(fn) { | |
return function (...args) { | |
return fn(...args).catch((err) => { | |
console.error('Ohhhh nooo!!!!!'); | |
console.error(err); | |
}); | |
} | |
} | |
const catchError = (fn) => (...params) => fn(...params).catch(e => console.error(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment