Published Jul 27, 2021Updated Sep 3, 2021
Contribute to Docs

Returns a new Promise related to a previously rejected Promise in the chain. This is ideal for formatting error messages for potential Promise rejections.



The rejectedPromiseCallback function will have access to all reject() data inside of myProjectObject.


Inside the brokenPromise is a single reject() call with error information. It is then handled inside .catch().

const brokenPromise = new Promise((resolve, reject) => {
errorType: 'Unknown error',
message: 'Something went wrong.',
brokenPromise.catch((err) => {
console.log(`${err.errorType}: ${err.message}`); // Unknown error: Something went wrong.

All contributors

Looking to contribute?

Learn JavaScript on Codecademy