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;
for (const individualError of error.errors) {
console.log(individualError);
}
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.