Skip to content

Instantly share code, notes, and snippets.

@mmarchini
Created August 10, 2020 21:53
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 mmarchini/61b9a3448cb5ee889dd9327cd86d5a7c to your computer and use it in GitHub Desktop.
Save mmarchini/61b9a3448cb5ee889dd9327cd86d5a7c to your computer and use it in GitHub Desktop.
promise-rejections.js
Promise.reject(new Error()); // This will result in a rejection
new Promise((fulfill, reject) => {
reject(new Error()); // This will result in a rejection
});
new Promise(() => {
throw new Error(); // This will result in a rejection
});
Promise.resolve().then(() => {
throw new Error(); // This will result in a rejection
});
Promise.reject().then(() => {}, () => {
throw new Error(); // This will result in a rejection
});
Promise.reject().catch(() => {
throw new Error(); // This will result in a rejection
});
Promise.resolve().finally(() => {
throw new Error(); // This will result in a rejection
});
async function foo() {
throw new Error(); // This will result in a rejection
}
async function bar(a) {
if (a === undefined)
a(); // This will result in a rejection
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment