Package Exports
- @flex-development/aggregate-error-ponyfill
- @flex-development/aggregate-error-ponyfill/native
- @flex-development/aggregate-error-ponyfill/package.json
- @flex-development/aggregate-error-ponyfill/ponyfill
Readme
aggregate-error-ponyfill
ES Proposal spec-compliant ponyfill for
AggregateError
.
TheAggregateError
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 byPromise.any()
, when all promises passed to it reject.
Install
yarn add @flex-development/aggregate-error-ponyfill
GitHub Package Registry
To install from the GitHub Package Registry, setup a .npmrc
or .yarnrc.yml
file to authenticate with the registry. A Personal Access Token with at least
the read:packages
scope is required.
.npmrc
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
@flex-development:registry=https://npm.pkg.github.com/
.yarnrc.yml
npmRegistries:
//npm.pkg.github.com:
npmAlwaysAuth: true
npmAuthToken: ${GITHUB_TOKEN}
npmScopes:
flex-development:
npmRegistryServer: https://npm.pkg.github.com
Git
See npm-install or Git - Protocols | Yarn for details on requesting a specific branch, commit, or tag.
NPM
npm i flex-development/aggregate-error-ponyfill
Yarn
yarn add @flex-development/aggregate-error-ponyfill@flex-development/aggregate-error-ponyfill
Usage
import AggregateError from '@flex-development/aggregate-error-ponyfill'
try {
throw new AggregateError([new Error('err1'), new Error('err2')], 'oh no!')
} catch (e) {
console.error(e.message) // 'oh no!'
console.error(e.name) // 'AggregateError'
console.error(e.errors) // [new Error('err1'), new Error('err2')]
}
Native
Depending on your environment, you can use the native AggregateError
instead
of the ponyfill:
import AggregateError from '@flex-development/aggregate-error-ponyfill/native'