Skip to content

Instantly share code, notes, and snippets.

@amysimmons
Last active June 11, 2018 12:06
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 amysimmons/567e66c25840203b123c4af19e2ddd53 to your computer and use it in GitHub Desktop.
Save amysimmons/567e66c25840203b123c4af19e2ddd53 to your computer and use it in GitHub Desktop.
var p1 = new Promise((resolve, reject) => {
  // throw Error('Something went wrong in the promise')
  resolve(42);
});

p1.then(
  (value) => {
    // throw Error('Something went wrong in the handler')
    console.log(value)
  },
  (error) => {
    // this would log if the Promise was rejected or 
    // an exception was thrown in the Promise 
    console.log(error);
  }
).catch((error) => {
  // this would log if an error occurred in the handler 
  console.log(error)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment