AggregateError() コンストラクター
AggregateError()
コンストラクターは、単一のエラーにラップする必要があるいくつかのエラーに対してエラーを作成します。
構文
new AggregateError(errors)
new AggregateError(errors, message)
引数
errors
-
エラーの反復可能オブジェクトであり、実際には
Error
インスタンスではない場合があります。 message
省略可-
オプションで、統合エラーの人間可読な説明です。
例
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" ]
}
仕様書
Specification |
---|
ECMAScript Language Specification # sec-aggregate-error-constructor |
ブラウザーの互換性
BCD tables only load in the browser
関連情報
AggregateError
のポリフィルがcore-js
で利用できますPromise.any