freeCodeCamp/guide/english/javascript/standard-objects/promise/promise-reject/index.md

21 lines
541 B
Markdown
Raw Normal View History

2018-10-12 19:37:13 +00:00
---
title: Promise Reject
---
## Promise Reject
A ```Promise.reject``` function returns an error condition to the calling function. It takes a single parameter, an Error object or value, as the reason for rejection.
Chaining a catch function at the end of a Promise caller will allow you to catch the error condition.
```javascript
promiseCallingFunction(paramList)
.then( ... )
...
.then( ... )
.catch( function(err) { // catch function
/*
* this is where you can access the reason for the rejection
*/
});
```