2019-10-31 01:37:42 +05:30
|
|
|
'use strict';
|
2019-09-25 13:30:05 +05:30
|
|
|
var $ = require('../internals/export');
|
2019-10-31 01:37:42 +05:30
|
|
|
var DESCRIPTORS = require('../internals/descriptors');
|
2019-09-25 13:30:05 +05:30
|
|
|
var getPrototypeOf = require('../internals/object-get-prototype-of');
|
|
|
|
var setPrototypeOf = require('../internals/object-set-prototype-of');
|
|
|
|
var create = require('../internals/object-create');
|
2019-10-31 01:37:42 +05:30
|
|
|
var defineProperty = require('../internals/object-define-property');
|
2019-09-25 13:30:05 +05:30
|
|
|
var createPropertyDescriptor = require('../internals/create-property-descriptor');
|
|
|
|
var iterate = require('../internals/iterate');
|
2019-10-31 01:37:42 +05:30
|
|
|
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
|
|
|
|
var anObject = require('../internals/an-object');
|
|
|
|
var InternalStateModule = require('../internals/internal-state');
|
|
|
|
|
|
|
|
var setInternalState = InternalStateModule.set;
|
|
|
|
var getInternalAggregateErrorState = InternalStateModule.getterFor('AggregateError');
|
2019-09-25 13:30:05 +05:30
|
|
|
|
|
|
|
var $AggregateError = function AggregateError(errors, message) {
|
|
|
|
var that = this;
|
|
|
|
if (!(that instanceof $AggregateError)) return new $AggregateError(errors, message);
|
|
|
|
if (setPrototypeOf) {
|
|
|
|
that = setPrototypeOf(new Error(message), getPrototypeOf(that));
|
|
|
|
}
|
|
|
|
var errorsArray = [];
|
|
|
|
iterate(errors, errorsArray.push, errorsArray);
|
2019-10-31 01:37:42 +05:30
|
|
|
if (DESCRIPTORS) setInternalState(that, { errors: errorsArray, type: 'AggregateError' });
|
|
|
|
else that.errors = errorsArray;
|
|
|
|
if (message !== undefined) createNonEnumerableProperty(that, 'message', String(message));
|
2019-09-25 13:30:05 +05:30
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
$AggregateError.prototype = create(Error.prototype, {
|
|
|
|
constructor: createPropertyDescriptor(5, $AggregateError),
|
2019-10-31 01:37:42 +05:30
|
|
|
message: createPropertyDescriptor(5, ''),
|
|
|
|
name: createPropertyDescriptor(5, 'AggregateError'),
|
|
|
|
toString: createPropertyDescriptor(5, function toString() {
|
|
|
|
var name = anObject(this).name;
|
|
|
|
name = name === undefined ? 'AggregateError' : String(name);
|
|
|
|
var message = this.message;
|
|
|
|
message = message === undefined ? '' : String(message);
|
|
|
|
return name + ': ' + message;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
if (DESCRIPTORS) defineProperty.f($AggregateError.prototype, 'errors', {
|
|
|
|
get: function () {
|
|
|
|
return getInternalAggregateErrorState(this).errors;
|
|
|
|
},
|
|
|
|
configurable: true
|
2019-09-25 13:30:05 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
$({ global: true }, {
|
|
|
|
AggregateError: $AggregateError
|
|
|
|
});
|