This package is an ECMAScript Proposal spec-compliant ponyfill for AggregateError
.
Use this package when you want to throw AggregateError
objects in unsupported environments (< es2021
).
yarn add @flex-development/aggregate-error-ponyfill
From Git:
yarn add @flex-development/aggregate-error-ponyfill@flex-development/aggregate-error-ponyfill
See Git - Protocols | Yarn for details on requesting a specific branch, commit, or tag.
import AggregateError from '@flex-development/aggregate-error-ponyfill'
try {
throw new AggregateError([new Error('some error')], 'oh no!')
} catch (e) {
console.debug(e instanceof AggregateError) // true
console.error(e.name) // 'AggregateError'
console.error(e.message) // 'oh no!'
console.error(e.errors) // [Error: 'some error']
}
This package exports no identifiers.
The default export is AggregateError
.
Wrap several errors in a single error so that multiple errors can be reported by an operation.
An iterable of errors.
An optional human-readable description of the aggregate error.
An object that has the following properties:
The specific cause of the aggregate error.
When catching and re-throwing an error with a more-specific or useful error message, this property can be used to pass the original error.
This package is fully typed with TypeScript.
See CONTRIBUTING.md
.