# @ardatan/aggregate-error

> Create an error from multiple errors

Latest version **0.0.6** (published 2020-09-04) · MIT license · 708.1K weekly downloads

## Install

```sh
npm install @ardatan/aggregate-error
pnpm add @ardatan/aggregate-error
yarn add @ardatan/aggregate-error
bun add @ardatan/aggregate-error
```

## Health

**Score 55/100 (C)** — status: abandoned.

Positive: moderate downloads; has types; esm support; no vulnerabilities; high maintenance score.

Warnings: pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-09-04 |
| First published | 2020-06-23 |
| Weekly downloads | 708.1K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 41.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 247 |
| Author | Sindre Sorhus |
| Maintainers | ardatan |
| Keywords | aggregate, error, combine, multiple, many, collection, iterable, iterator |

## Links

- npm: https://www.npmjs.com/package/@ardatan/aggregate-error
- Repository: https://github.com/sindresorhus/aggregate-error
- Homepage: https://github.com/sindresorhus/aggregate-error#readme
- Issues: https://github.com/sindresorhus/aggregate-error/issues
- npm.io page: https://npm.io/package/@ardatan/aggregate-error

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ~2.0.1

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads
- [@vorionsys/shared-constants](https://npm.io/package/@vorionsys/shared-constants.md) — 26 weekly downloads

## Recent versions

- 0.0.6 (latest) — 2020-09-04
- 0.0.5 — 2020-09-04
- 0.0.4 — 2020-09-04
- 0.0.3 — 2020-09-04
- 0.0.2 — 2020-09-03
- 0.0.1 — 2020-06-23

## README

# aggregate-error [![Build Status](https://travis-ci.org/sindresorhus/aggregate-error.svg?branch=master)](https://travis-ci.org/sindresorhus/aggregate-error)

> Create an error from multiple errors


## Install

```
$ npm install aggregate-error
```


## Usage

```js
const AggregateError = require('aggregate-error');

const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);

throw error;
/*
AggregateError:
    Error: foo
        at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:33)
    Error: bar
        at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
    Error: baz
        at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
    at AggregateError (/Users/sindresorhus/dev/aggregate-error/index.js:19:3)
    at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
*/

for (const individualError of error) {
	console.log(individualError);
}
//=> [Error: foo]
//=> [Error: bar]
//=> [Error: baz]
```


## API

### AggregateError(errors)

Returns an `Error` that is also an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Iterables) for the individual errors.

#### errors

Type: `Array<Error|Object|string>`

If a string, a new `Error` is created with the string as the error message.<br>
If a non-Error object, a new `Error` is created with all properties from the object copied over.

---
_Source: https://npm.io/package/@ardatan/aggregate-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
