debian-mirror-gitlab/core-js/modules/esnext.aggregate-error.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-09-25 13:30:05 +05:30
var $ = require('../internals/export');
var getPrototypeOf = require('../internals/object-get-prototype-of');
var setPrototypeOf = require('../internals/object-set-prototype-of');
var create = require('../internals/object-create');
var createPropertyDescriptor = require('../internals/create-property-descriptor');
var iterate = require('../internals/iterate');
var hide = require('../internals/hide');
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);
hide(that, 'errors', errorsArray);
if (message !== undefined) hide(that, 'message', String(message));
return that;
};
$AggregateError.prototype = create(Error.prototype, {
constructor: createPropertyDescriptor(5, $AggregateError),
name: createPropertyDescriptor(5, 'AggregateError')
});
$({ global: true }, {
AggregateError: $AggregateError
});