source: trip-planner-front/node_modules/aggregate-error/index.d.ts@ 571e0df

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

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2Create an error from multiple errors.
3*/
4declare class AggregateError<T extends Error = Error> extends Error implements Iterable<T> {
5 readonly name: 'AggregateError';
6
7 /**
8 @param errors - 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.
9 @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.
10
11 @example
12 ```
13 import AggregateError = require('aggregate-error');
14
15 const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
16
17 throw error;
18
19 // AggregateError:
20 // Error: foo
21 // at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:33)
22 // Error: bar
23 // at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
24 // Error: baz
25 // at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
26 // at AggregateError (/Users/sindresorhus/dev/aggregate-error/index.js:19:3)
27 // at Object.<anonymous> (/Users/sindresorhus/dev/aggregate-error/example.js:3:13)
28 // at Module._compile (module.js:556:32)
29 // at Object.Module._extensions..js (module.js:565:10)
30 // at Module.load (module.js:473:32)
31 // at tryModuleLoad (module.js:432:12)
32 // at Function.Module._load (module.js:424:3)
33 // at Module.runMain (module.js:590:10)
34 // at run (bootstrap_node.js:394:7)
35 // at startup (bootstrap_node.js:149:9)
36
37
38 for (const individualError of error) {
39 console.log(individualError);
40 }
41 //=> [Error: foo]
42 //=> [Error: bar]
43 //=> [Error: baz]
44 ```
45 */
46 constructor(errors: ReadonlyArray<T | {[key: string]: any} | string>);
47
48 [Symbol.iterator](): IterableIterator<T>;
49}
50
51export = AggregateError;
Note: See TracBrowser for help on using the repository browser.