Last active
July 21, 2016 20:55
-
-
Save xjamundx/7c45b9e200cdeab31b8383566dfc9083 to your computer and use it in GitHub Desktop.
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
// basic error handling with async functions | |
async function getData(param) { | |
if (isBad(param)) { | |
throw new Error("this is a bad param") | |
} | |
// ... | |
} | |
// basic promise-based error handling example | |
function getData(param) { | |
if (isBad(param)) { | |
return Promise.reject(new Error("this is a bad param")) | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment