Dev HelpersOpen library
← Back

Collect multiple errors

Collect multiple errors in JavaScript.

Open this example in the interactive library

Source code

const errors = new AggregateError(
  [new Error("first"), new Error("second")],
  "Batch failed",
);
console.log(errors.errors.map((error) => error.message));

Sample output

[ 'first', 'second' ]