Constructeur AggregateError()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2020.
Le constructeur AggregateError()
permet de créer une erreur qui agrège plusieurs erreurs.
Syntaxe
js
new AggregateError(erreurs);
new AggregateError(erreurs, message);
Paramètres
erreurs
-
Un objet itérable contenant des erreurs (qui peuvent ne pas être des instances de
Error
). message
Facultatif-
Une description optionnelle, compréhensible par un humain, de l'erreur agrégée.
Exemples
Créer une exception AggregateError
js
try {
throw new AggregateError([new Error("une erreur")], "Coucou");
} catch (e) {
console.log(e instanceof AggregateError); // true
console.log(e.message); // "Coucou"
console.log(e.name); // "AggregateError"
console.log(e.errors); // [ Error: "une erreur" ]
}
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-aggregate-error-constructor |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AggregateError() constructor |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.