source: node_modules/core-js-pure/modules/esnext.suppressed-error.constructor.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var isPrototypeOf = require('../internals/object-is-prototype-of');
4var getPrototypeOf = require('../internals/object-get-prototype-of');
5var setPrototypeOf = require('../internals/object-set-prototype-of');
6var copyConstructorProperties = require('../internals/copy-constructor-properties');
7var create = require('../internals/object-create');
8var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
9var createPropertyDescriptor = require('../internals/create-property-descriptor');
10var installErrorStack = require('../internals/error-stack-install');
11var normalizeStringArgument = require('../internals/normalize-string-argument');
12var wellKnownSymbol = require('../internals/well-known-symbol');
13
14var TO_STRING_TAG = wellKnownSymbol('toStringTag');
15var $Error = Error;
16
17var $SuppressedError = function SuppressedError(error, suppressed, message) {
18 var isInstance = isPrototypeOf(SuppressedErrorPrototype, this);
19 var that;
20 if (setPrototypeOf) {
21 that = setPrototypeOf(new $Error(), isInstance ? getPrototypeOf(this) : SuppressedErrorPrototype);
22 } else {
23 that = isInstance ? this : create(SuppressedErrorPrototype);
24 createNonEnumerableProperty(that, TO_STRING_TAG, 'Error');
25 }
26 if (message !== undefined) createNonEnumerableProperty(that, 'message', normalizeStringArgument(message));
27 installErrorStack(that, $SuppressedError, that.stack, 1);
28 createNonEnumerableProperty(that, 'error', error);
29 createNonEnumerableProperty(that, 'suppressed', suppressed);
30 return that;
31};
32
33if (setPrototypeOf) setPrototypeOf($SuppressedError, $Error);
34else copyConstructorProperties($SuppressedError, $Error, { name: true });
35
36var SuppressedErrorPrototype = $SuppressedError.prototype = create($Error.prototype, {
37 constructor: createPropertyDescriptor(1, $SuppressedError),
38 message: createPropertyDescriptor(1, ''),
39 name: createPropertyDescriptor(1, 'SuppressedError')
40});
41
42// `SuppressedError` constructor
43// https://github.com/tc39/proposal-explicit-resource-management
44$({ global: true, constructor: true, arity: 3 }, {
45 SuppressedError: $SuppressedError
46});
Note: See TracBrowser for help on using the repository browser.