source: trip-planner-front/node_modules/aggregate-error/readme.md@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[6a3a178]1# aggregate-error [![Build Status](https://travis-ci.org/sindresorhus/aggregate-error.svg?branch=master)](https://travis-ci.org/sindresorhus/aggregate-error)
2
3> Create an error from multiple errors
4
5
6## Install
7
8```
9$ npm install aggregate-error
10```
11
12
13## Usage
14
15```js
16const AggregateError = require('aggregate-error');
17
18const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
19
20throw error;
21/*
22AggregateError:
23 Error: foo
24 at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:33)
25 Error: bar
26 at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
27 Error: baz
28 at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
29 at AggregateError (/Users/sindresorhus/dev/aggregate-error/index.js:19:3)
30 at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
31 at Module._compile (module.js:556:32)
32 at Object.Module._extensions..js (module.js:565:10)
33 at Module.load (module.js:473:32)
34 at tryModuleLoad (module.js:432:12)
35 at Function.Module._load (module.js:424:3)
36 at Module.runMain (module.js:590:10)
37 at run (bootstrap_node.js:394:7)
38 at startup (bootstrap_node.js:149:9)
39*/
40
41for (const individualError of error) {
42 console.log(individualError);
43}
44//=> [Error: foo]
45//=> [Error: bar]
46//=> [Error: baz]
47```
48
49
50## API
51
52### AggregateError(errors)
53
54Returns 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.
55
56#### errors
57
58Type: `Array<Error|Object|string>`
59
60If a string, a new `Error` is created with the string as the error message.<br>
61If a non-Error object, a new `Error` is created with all properties from the object copied over.
Note: See TracBrowser for help on using the repository browser.