AggregateError() constructor creates an error for several errors that need to be wrapped in a single error.

句法

new AggregateError(errors[, message])
					

参数

errors
An iterable of errors, may not actually be Error 实例。
message 可选

An optional human-readable description of the aggregate error.

范例

Creating an AggregateError

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.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
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

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改: