Created
December 27, 2017 08:05
-
-
Save 5aurabh/0905bbe77ad6bbf252b2293ace58936e to your computer and use it in GitHub Desktop.
Example - UnhandledPromiseRejectionWarning
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 p1 (){ | |
return new Promise(function(resolve, reject){ | |
resolve({message: 'p1 resolved'}); | |
}) | |
} | |
function test(){ | |
let unresolvePromise = Promise.reject({message: 'meant to be rejected'}); | |
unresolvePromise = p1(); | |
return unresolvePromise.then(function(data){ | |
return data; | |
}) | |
.catch(function(err){ | |
console.log(err); | |
return null | |
}) | |
.then(function(data){ | |
console.log('caught all errors.') | |
console.log(data) | |
}) | |
.catch(function(err){ | |
console.log('Error Caught') | |
console.log(err) | |
}) | |
} | |
test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment