https://github.com/flex-development/aggregate-error-ponyfill
ECMAScript Proposal spec-compliant ponyfill for AggregateError
https://github.com/flex-development/aggregate-error-ponyfill
aggregate-error ecmascript es-proposal polyfill ponyfill typescript
Last synced: 5 months ago
JSON representation
ECMAScript Proposal spec-compliant ponyfill for AggregateError
- Host: GitHub
- URL: https://github.com/flex-development/aggregate-error-ponyfill
- Owner: flex-development
- License: bsd-3-clause
- Created: 2022-08-27T03:01:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T21:07:58.000Z (over 1 year ago)
- Last Synced: 2025-02-16T05:01:43.680Z (5 months ago)
- Topics: aggregate-error, ecmascript, es-proposal, polyfill, ponyfill, typescript
- Language: JavaScript
- Homepage: https://github.com/flex-development/aggregate-error-ponyfill
- Size: 3.03 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# aggregate-error-ponyfill
[](https://npmjs.com/package/@flex-development/aggregate-error-ponyfill)
[](https://codecov.io/gh/flex-development/aggregate-error-ponyfill)
[](https://github.com/voxpelli/badges-cjs-esm)
[](LICENSE.md)
[](https://conventionalcommits.org/)
[](https://typescriptlang.org/)
[](https://vitest.dev/)
[](https://yarnpkg.com/)[`AggregateError`][1] [ponyfill][2].
## Contents
- [What is this?](#what-is-this)
- [When should I use this?](#when-should-i-use-this)
- [Install](#install)
- [Use](#use)
- [API](#api)
- [Types](#types)
- [Interfaces](#interfaces)
- [Contribute](#contribute)## What is this?
This package is an ECMAScript Proposal spec-compliant [ponyfill][2] for [`AggregateError`][1].
## When should I use this?
Use this package when you want to throw `AggregateError` objects in unsupported environments (`< es2021`).
## Install
```sh
yarn add @flex-development/aggregate-error-ponyfill
```From Git:
```sh
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.
## Use
```javascript
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']
}
```## API
This package exports no identifiers.
The default export is `AggregateError`.
###
`new AggregateError(errors: Iterable, message?: string, options?: Options)`
Wrap several errors in a single error so that multiple errors can be reported by an operation.
#### `errors`
An iterable of errors.
#### `message`
An optional human-readable description of the aggregate error.
#### `options`
An object that has the following properties:
##### `cause`
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.## Types
This package is fully typed with [TypeScript][3].
### Interfaces
- [`Options`](src/options.ts)
## Contribute
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AggregateError
[2]: https://github.com/sindresorhus/ponyfill
[3]: https://www.typescriptlang.org