| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- 'use strict';
- var $ = require('../internals/export');
- var isPrototypeOf = require('../internals/object-is-prototype-of');
- var getPrototypeOf = require('../internals/object-get-prototype-of');
- var setPrototypeOf = require('../internals/object-set-prototype-of');
- var copyConstructorProperties = require('../internals/copy-constructor-properties');
- var create = require('../internals/object-create');
- var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
- var createPropertyDescriptor = require('../internals/create-property-descriptor');
- var clearErrorStack = require('../internals/error-stack-clear');
- var installErrorCause = require('../internals/install-error-cause');
- var normalizeStringArgument = require('../internals/normalize-string-argument');
- var wellKnownSymbol = require('../internals/well-known-symbol');
- var ERROR_STACK_INSTALLABLE = require('../internals/error-stack-installable');
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
- var $Error = Error;
- var $SuppressedError = function SuppressedError(error, suppressed, message /* , options */) {
- var options = arguments.length > 3 ? arguments[3] : undefined;
- var isInstance = isPrototypeOf(SuppressedErrorPrototype, this);
- var that;
- if (setPrototypeOf) {
- that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : SuppressedErrorPrototype);
- } else {
- that = isInstance ? this : create(SuppressedErrorPrototype);
- createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
- }
- if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
- if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty(that, 'stack', clearErrorStack(that.stack, 1));
- installErrorCause(that, options);
- createNonEnumerableProperty(that, 'error', error);
- createNonEnumerableProperty(that, 'suppressed', suppressed);
- return that;
- };
- if (setPrototypeOf) setPrototypeOf($SuppressedError, $Error);
- else copyConstructorProperties($SuppressedError, $Error, { name: true });
- var SuppressedErrorPrototype = $SuppressedError.prototype = create($Error.prototype, {
- constructor: createPropertyDescriptor(1, $SuppressedError),
- message: createPropertyDescriptor(1, ''),
- name: createPropertyDescriptor(1, 'SuppressedError')
- });
- // `SuppressedError` constructor
- // https://github.com/tc39/proposal-explicit-resource-management
- $({ global: true, constructor: true, arity: 3 }, {
- SuppressedError: $SuppressedError
- });
|