Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
971 B

  1. 'use strict';
  2. const indentString = require('indent-string');
  3. const cleanStack = require('clean-stack');
  4. const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, '');
  5. class AggregateError extends Error {
  6. constructor(errors) {
  7. // Even though strings are iterable, we don't allow them to prevent subtle user mistakes
  8. if (!errors[Symbol.iterator] || typeof errors === 'string') {
  9. throw new TypeError(`Expected input to be iterable, got ${typeof errors}`);
  10. }
  11. errors = Array.from(errors).map(err => err instanceof Error ? err : new Error(err));
  12. let message = errors.map(err => cleanInternalStack(cleanStack(err.stack))).join('\n');
  13. message = '\n' + indentString(message, 4);
  14. super(message);
  15. this.name = this.constructor.name;
  16. Object.defineProperty(this, '_errors', {value: errors});
  17. }
  18. * [Symbol.iterator]() {
  19. for (const error of this._errors) {
  20. yield error;
  21. }
  22. }
  23. }
  24. module.exports = AggregateError;