Last active
February 19, 2019 05:34
-
-
Save keyvan-m-sadeghi/0cb8be3055efaba37c8e848a38bd5a66 to your computer and use it in GitHub Desktop.
This file contains 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
const anything = () => { | |
throw new Error('I can be anything because I should never get called!'); | |
}; | |
const throwSomethingWrong = () => { | |
console.log('not ignored!'); | |
throw new Error('Something went wrong...'); | |
}; | |
const p = Nancy.reject(42) | |
.catch(value => value) // resolves | |
.catch(anything) // ignored | |
.catch(anything) // ignored | |
.then(value => console.log(value)) // logs 42 | |
.then(throwSomethingWrong) // logs not ignored! | |
.catch(throwSomethingWrong) // logs not ignored! | |
.catch(() => 24); // resolves | |
// p is a Nancy | |
// p.state is states.resolved | |
// p.value is 24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment