Skip to content

Instantly share code, notes, and snippets.

@jboxman
Created April 16, 2017 16:35
Show Gist options
  • Save jboxman/87953713660edf1f41114f7c38662661 to your computer and use it in GitHub Desktop.
Save jboxman/87953713660edf1f41114f7c38662661 to your computer and use it in GitHub Desktop.
var rejectedPromise = Promise.reject(new Error('Whatever'));
const p = new Promise(
(fulfill, reject) => {
setTimeout(() => rejectedPromise.then(fulfill, reject), 1000);
}
);
p.then(value => console.log(value)).catch(console.log('rejected'));
/*
rejected
(node:5476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Whatever
(node:5476) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will term
inate the Node.js process with a non-zero exit code.
(node:5476) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:5476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Whatever
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment