Skip to content

Instantly share code, notes, and snippets.

@keyvan-m-sadeghi
Last active February 19, 2019 05:34
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 keyvan-m-sadeghi/0cb8be3055efaba37c8e848a38bd5a66 to your computer and use it in GitHub Desktop.
Save keyvan-m-sadeghi/0cb8be3055efaba37c8e848a38bd5a66 to your computer and use it in GitHub Desktop.
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