Created
December 10, 2017 16:46
-
-
Save welll/fa4e6d53e1fd77eb8fccd22e687d656d 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
let myAsyncFunctionThatReturnsPromise = new Promise((resolve, reject) => { | |
setTimeout(function(){ | |
resolve("Success!") | |
}, 2500) | |
}) | |
let foo1 = Promise.resolve() | |
.then(function(){ callUndefinedFunction() }) | |
.catch((e)=> console.log(`Error: ${e}`)) | |
let foo2 = Promise.reject('Promise was Rejected') | |
.then(function(){ throw Error('x') }) | |
.catch((e)=> { | |
console.log(`Error: ${e}`) | |
callUndefineFunctionHereAtCathcBlock() | |
}) | |
myAsyncFunctionThatReturnsPromise.then((resolvedValue) => { | |
console.log(`resolvedValue: ${resolvedValue}`) | |
}).catch( (error) => { | |
console.log(`resolvedValue: ${resolvedValue}`) | |
}) | |
new Promise((_, reject) => reject(new Error('woops'))). | |
catch(error => { | |
// Will not execute | |
console.log('caught', error.message); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment