Skip to content

[email protected] (🎂 First Release)

Compare
Choose a tag to compare
@unicornware unicornware released this 04 Nov 19:05
· 177 commits to main since this release
33741b3

Overview

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.

Usage

import AggregateError from '@flex-development/aggregate-error-ponyfill'

try {
  throw new AggregateError([new Error('some error')], 'Hello')
} catch (error) {
  console.error(error instanceof AggregateError) // true
  console.error(error.message) // "Hello"
  console.error(error.name) // "AggregateError"
  console.error(error.errors) // [ Error: "some error" ]
}