- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Promise Errors
JavaScript Asynchronous
JavaScript Promise Errors
catchhandles a rejected promise, andfinallyruns whatever happened.
An error inside a promise does not crash the program; it rejects the promise.
If nothing catches it, the browser reports an unhandled rejection.
Example
Example
javascript
Promise.reject(new Error("no network"))
.catch(function (error) {
console.log("caught: " + error.message);
});