AggregateError
object represents an error when several errors need to be wrapped in a single error. It is thrown when multiple errors need to be reported by an operation, for example by
Promise.any()
, when all promises passed to it reject.
AggregateError()
AggregateError
对象。
AggregateError.prototype.message
""
.
AggregateError.prototype.name
AggregateError
.
Promise.any([
Promise.reject(new Error("some error")),
]).catch(e => {
console.log(e instanceof AggregateError); // true
console.log(e.message); // "All Promises rejected"
console.log(e.name); // "AggregateError"
console.log(e.errors); // [ Error: "some error" ]
});
try {
throw new AggregateError([
new Error("some error"),
], 'Hello');
} catch (e) {
console.log(e instanceof AggregateError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "AggregateError"
console.log(e.errors); // [ Error: "some error" ]
}
| 规范 |
|---|
|
Promise.any
The definition of 'AggregateError' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AggregateError
|
Chrome 85 | Edge No | Firefox 79 | IE No | Opera No | Safari 14 | WebView Android 85 | Chrome Android 85 | Firefox Android No | Opera Android No | Safari iOS 14 | Samsung Internet Android No | nodejs No |
AggregateError()
构造函数
|
Chrome 85 | Edge No | Firefox 79 | IE No | Opera No | Safari 14 | WebView Android 85 | Chrome Android 85 | Firefox Android No | Opera Android No | Safari iOS 14 | Samsung Internet Android No | nodejs No |
完整支持
不支持
AggregateError
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()