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

22 lines
511 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: Promise Reject
localeTitle: 承诺拒绝
---
## 承诺拒绝
`Promise.reject`函数向调用函数返回错误条件。它需要一个参数一个Error对象或值作为拒绝的原因。
在Promise调用者的末尾链接catch函数将允许您捕获错误条件。
```javascript
promiseCallingFunction(paramList)
.then( ... )
...
.then( ... )
.catch( function(err) { // catch function
/*
* this is where you can access the reason for the rejection
*/
});
```