Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Last active July 21, 2016 20:55
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 xjamundx/7c45b9e200cdeab31b8383566dfc9083 to your computer and use it in GitHub Desktop.
Save xjamundx/7c45b9e200cdeab31b8383566dfc9083 to your computer and use it in GitHub Desktop.
// 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