JSPM

@flex-development/aggregate-error-ponyfill

2.0.0-alpha.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 237
  • Score
    100M100P100Q95923F
  • License BSD-3-Clause

ES Proposal spec-compliant ponyfill for AggregateError

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

conventional commits code style: prettier npm license typescript

ES Proposal spec-compliant ponyfill for AggregateError.
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.

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'