Skip to content

Commit 02ed713

Browse files
Sebastien-Ahkrintargos
authored andcommitted
lib: replace use of Error with primordials
PR-URL: #31163 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent e5b7d64 commit 02ed713

29 files changed

+34
-0
lines changed

lib/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ rules:
1515
message: "Use `const { BigInt } = primordials;` instead of the global."
1616
- name: Boolean
1717
message: "Use `const { Boolean } = primordials;` instead of the global."
18+
- name: Error
19+
message: "Use `const { Error } = primordials;` instead of the global."
1820
- name: JSON
1921
message: "Use `const { JSON } = primordials;` instead of the global."
2022
- name: Math

lib/_http_client.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ArrayIsArray,
2626
Boolean,
27+
Error,
2728
NumberIsFinite,
2829
ObjectAssign,
2930
ObjectKeys,

lib/_http_server.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const {
25+
Error,
2526
ObjectKeys,
2627
ObjectSetPrototypeOf,
2728
Symbol,

lib/assert.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'use strict';
2222

2323
const {
24+
Error,
2425
ObjectAssign,
2526
ObjectIs,
2627
ObjectKeys,

lib/buffer.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
Array,
2626
ArrayIsArray,
27+
Error,
2728
MathFloor,
2829
MathMin,
2930
MathTrunc,

lib/child_process.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
ArrayIsArray,
26+
Error,
2627
NumberIsInteger,
2728
ObjectAssign,
2829
ObjectDefineProperty,

lib/domain.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
const {
3030
Array,
31+
Error,
3132
ObjectDefineProperty,
3233
ReflectApply,
3334
Symbol,

lib/events.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
Array,
26+
Error,
2627
MathMin,
2728
NumberIsNaN,
2829
ObjectCreate,

lib/internal/assert/assertion_error.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
Error,
45
MathMax,
56
ObjectCreate,
67
ObjectDefineProperty,

lib/internal/async_hooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
Error,
45
FunctionPrototypeBind,
56
NumberIsSafeInteger,
67
ObjectDefineProperty,

lib/internal/bootstrap/loaders.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
/* global process, getLinkedBinding, getInternalBinding, primordials */
4545

4646
const {
47+
Error,
4748
ReflectGet,
4849
ObjectCreate,
4950
ObjectDefineProperty,

lib/internal/console/constructor.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {
77
ArrayFrom,
88
ArrayIsArray,
99
Boolean,
10+
Error,
1011
ObjectDefineProperties,
1112
ObjectDefineProperty,
1213
ObjectKeys,

lib/internal/error-serdes.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const Buffer = require('buffer').Buffer;
44
const {
55
ArrayPrototypeForEach,
6+
Error,
67
FunctionPrototypeCall,
78
ObjectAssign,
89
ObjectCreate,

lib/internal/errors.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
const {
1414
ArrayIsArray,
15+
Error,
1516
MathAbs,
1617
NumberIsInteger,
1718
ObjectDefineProperty,

lib/internal/fs/utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ArrayIsArray,
55
BigInt,
66
DateNow,
7+
Error,
78
Number,
89
NumberIsFinite,
910
ObjectSetPrototypeOf,

lib/internal/http2/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ArrayIsArray,
5+
Error,
56
MathMax,
67
Number,
78
ObjectCreate,

lib/internal/modules/cjs/loader.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
ArrayIsArray,
26+
Error,
2627
JSONParse,
2728
ObjectCreate,
2829
ObjectDefineProperty,

lib/internal/per_context/domexception.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
Error,
45
ObjectDefineProperties,
56
ObjectDefineProperty,
67
SafeWeakMap,

lib/internal/process/promises.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const {
4+
Error,
45
ObjectDefineProperty,
56
WeakMap,
67
} = primordials;

lib/internal/process/warning.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {
44
ArrayIsArray,
5+
Error,
56
} = primordials;
67

78
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;

lib/internal/source_map/prepare_stack_trace.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
const {
4+
Error,
5+
} = primordials;
6+
37
const debug = require('internal/util/debuglog').debuglog('source_map');
48
const { findSourceMap } = require('internal/source_map/source_map_cache');
59
const {

lib/internal/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const {
44
ArrayFrom,
55
ArrayIsArray,
6+
Error,
67
ObjectCreate,
78
ObjectDefineProperties,
89
ObjectDefineProperty,

lib/internal/util/comparisons.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
BigIntPrototypeValueOf,
66
BooleanPrototypeValueOf,
77
DatePrototypeGetTime,
8+
Error,
89
NumberIsNaN,
910
NumberPrototypeValueOf,
1011
ObjectGetOwnPropertySymbols,

lib/internal/v8_prof_polyfill.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28+
/* eslint-disable no-restricted-globals */
29+
2830
module.exports = { versionCheck };
2931

3032
// Don't execute when required directly instead of being eval'd from

lib/net.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
const {
2525
ArrayIsArray,
2626
Boolean,
27+
Error,
2728
Number,
2829
NumberIsNaN,
2930
ObjectDefineProperty,

lib/repl.js

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
const {
4646
ArrayIsArray,
47+
Error,
4748
MathMax,
4849
NumberIsNaN,
4950
ObjectAssign,

lib/util.js

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
const {
2525
ArrayIsArray,
26+
Error,
2627
NumberIsSafeInteger,
2728
ObjectDefineProperties,
2829
ObjectDefineProperty,

lib/v8.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
const {
1818
Array,
1919
ArrayBuffer,
20+
Error,
2021
Float32Array,
2122
Float64Array,
2223
Int16Array,

lib/zlib.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'use strict';
2323

2424
const {
25+
Error,
2526
MathMax,
2627
NumberIsFinite,
2728
NumberIsNaN,

0 commit comments

Comments
 (0)