<commit_before>const message = Symbol();

export default class MultiError extends Error {
	constructor(errors, prefix) {
		super();
		Object.defineProperties(
			this,
			{
				"_prefix": {
					enumerable: false,
					writable: true,
					value: prefix
				},
				"errors": {
					writable: false,
					enumerable: true,
					value: []
				},
				"message": {
					get: this[message]
				}
			}
		);

		this.name = prefix; //so it has title to group by on jsonapi

		if (Array.isArray(errors)) {
			errors.forEach((error) => {
				this.push(error);
			});
		} else if (errors instanceof Error) {
			this.push(errors);
		}
	}

	push(newError) {
		if (newError.constructor.name === this.constructor.name) {
			newError.errors.forEach((error) => {
				error.name = this._prefix || error.name;
				this.errors.push(error);
			});
		} else {
			newError.name = this._prefix || newError.name;
			this.errors.push(newError);
		}
	}

	toJSON() {
		let result = [];
		this.errors.forEach((error) => {
			//standard ERROR properties from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
			result.push({name: error.name, message: error.message});
		});
		return result;
	}

	[message]() {
		let returnedMessage = "";
		if(this._prefix) {
			returnedMessage = this._prefix + ": ";
		}

		returnedMessage += this.errors.map((error) => {
			return error.message;<commit_msg>test for ie9<commit_after>const message = Symbol();

export default class MultiError extends Error {
	constructor(errors, prefix) {
		super();
		Object.defineProperties(
			this,
			{
				"_prefix": {
					enumerable: false,
					writable: true,
					value: prefix
				},
				"errors": {
					writable: false,
					enumerable: true,
					value: []
				},
				"message": {
					get: this[message]
				}
			}
		);

		this.name = prefix; //so it has title to group by on jsonapi

		if (Array.isArray(errors)) {
			errors.forEach((error) => {
				this.push(error);
			});
		} else if (errors instanceof Error) {
			this.push(errors);
		}
	}

	push(newError) {
		if (newError.constructor.name === this.constructor.name) {
			newError.errors.forEach((error) => {
				error.name = this._prefix || error.name;
				this.errors.push(error);
			});
		} else {
			newError.name = this._prefix || newError.name;
			this.errors.push(newError);
		}
	}

	toJSON() {
		let result = new Array();
		this.errors.forEach((error) => {
			//standard ERROR properties from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
			result.push({name: error.name, message: error.message});
		});
		return result;
	}

	[message]() {
		let returnedMessage = "";
		if(this._prefix) {
			returnedMessage = this._prefix + ": ";
		}

		returnedMessage += this.errors.map((error) => {
			return error.message;
{'fraction_non_alphanumeric': 0.15669515669515668, 'fraction_numerical': 0.00035612535612535614, 'mean_word_length': 2.934173669467787, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2186212', 'n_tokens_mistral': 1142, 'n_tokens_neox': 916, 'n_words': 183}