Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

aggregate-error

Package Overview
Dependencies
2
Maintainers
1
Versions
10
Issues
File Explorer

Advanced tools

aggregate-error

Create an error from multiple errors

    4.0.1latest

Version published
Maintainers
1
Weekly downloads
19,322,769
increased by1.35%

Weekly downloads

Changelog

Source

  • Fix handling of errors with empty stack trace (#19) 74a869b

https://github.com/sindresorhus/aggregate-error/compare/v4.0.0...v4.0.1

Readme

Source

aggregate-error

Create an error from multiple errors

Note: With Node.js 15, there's now a built-in AggregateError type.

Install

$ npm install aggregate-error

Usage

import AggregateError from '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.errors) { console.log(individualError); } //=> [Error: foo] //=> [Error: bar] //=> [Error: baz]

API

AggregateError(errors)

Returns an Error.

errors

Type: Array<Error|object|string>

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

Keywords

FAQs

What is aggregate-error?

Create an error from multiple errors

Is aggregate-error popular?

The npm package aggregate-error receives a total of 16,795,456 weekly downloads. As such, aggregate-error popularity was classified as popular.

Is aggregate-error well maintained?

We found that aggregate-error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 08 May 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc