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

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