I recently noticed the new AggregateError
object (ECMAScript 2021). Is there any cases or best practices where it is recommended to use it?
Description from the MDN wiki:
The 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.
So, use it whenever the description fits - if you want to throw multiple errors at once.