Created
June 4, 2015 04:53
-
-
Save ajcrites/941c8ed3e61d731cdbef 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
Promise.resolve(process.hrtime()) | |
.then(returnAPromise) | |
.then(returnAValue) | |
.then(returnAPromise) | |
.then(throwAnException) | |
.catch(handleExceptionAndReturnPromise) | |
.then(returnAPromise) | |
.then(throwAnException) | |
.catch(handleFinalException) | |
function returnAPromise(value) { | |
console.log(value); | |
return Promise.resolve(process.hrtime()); | |
} | |
function returnAValue(value) { | |
console.log(value); | |
return process.hrtime(); | |
} | |
function handleFinalException(error) { | |
console.log("all done", error); | |
} | |
function throwAnException(value) { | |
console.log(value, "about to throw!"); | |
throw "exception thrown!"; | |
} | |
function handleExceptionAndReturnPromise(error) { | |
console.log(error); | |
return Promise.resolve(process.hrtime()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment