lib: use global Error constructors from primordials

PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
This commit is contained in:
Michaël Zasso authored and Node.js GitHub Bot committed 2020-10-07 13:44:19 +00:00
1 parent 46526d6cad
commit 4bc4f88ca1
8 files changed
+34 -1

No files matched your search

+12
View File
@@ -21,6 +21,8 @@ rules:
message: "Use `const { Boolean } = primordials;` instead of the global."
- name: Error
message: "Use `const { Error } = primordials;` instead of the global."
- name: EvalError
message: "Use `const { EvalError } = primordials;` instead of the global."
- name: Float32Array
message: "Use `const { Float32Array } = primordials;` instead of the global."
- name: Float64Array
@@ -43,6 +45,10 @@ rules:
message: "Use `const { Object } = primordials;` instead of the global."
- name: Promise
message: "Use `const { Promise } = primordials;` instead of the global."
- name: RangeError
message: "Use `const { RangeError } = primordials;` instead of the global."
- name: ReferenceError
message: "Use `const { ReferenceError } = primordials;` instead of the global."
- name: Reflect
message: "Use `const { Reflect } = primordials;` instead of the global."
- name: RegExp
@@ -53,6 +59,12 @@ rules:
message: "Use `const { String } = primordials;` instead of the global."
- name: Symbol
message: "Use `const { Symbol } = primordials;` instead of the global."
- name: SyntaxError
message: "Use `const { SyntaxError } = primordials;` instead of the global."
- name: TypeError
message: "Use `const { TypeError } = primordials;` instead of the global."
- name: URIError
message: "Use `const { URIError } = primordials;` instead of the global."
- name: Uint16Array
message: "Use `const { Uint16Array } = primordials;` instead of the global."
- name: WeakMap
+1
View File
@@ -53,6 +53,7 @@ const {
ReflectGet,
SafeSet,
String,
TypeError,
} = primordials;
// Set up process.moduleLoadList.
+6
View File
@@ -4,6 +4,7 @@ const Buffer = require('buffer').Buffer;
const {
ArrayPrototypeForEach,
Error,
EvalError,
FunctionPrototypeCall,
ObjectAssign,
ObjectCreate,
@@ -13,8 +14,13 @@ const {
ObjectGetPrototypeOf,
ObjectKeys,
ObjectPrototypeToString,
RangeError,
ReferenceError,
SafeSet,
SymbolToStringTag,
SyntaxError,
TypeError,
URIError,
} = primordials;
const kSerializedError = 0;
+4
View File
@@ -21,10 +21,14 @@ const {
NumberIsInteger,
ObjectDefineProperty,
ObjectKeys,
RangeError,
String,
StringPrototypeStartsWith,
Symbol,
SymbolFor,
SyntaxError,
TypeError,
URIError,
WeakMap,
} = primordials;
+1
View File
@@ -7,6 +7,7 @@ const {
SafeWeakMap,
SafeMap,
SymbolToStringTag,
TypeError,
} = primordials;
class ERR_INVALID_THIS extends TypeError {
+6
View File
@@ -125,6 +125,7 @@ primordials.SafePromise = makeSafe(
'Boolean',
'Date',
'Error',
'EvalError',
'Float32Array',
'Float64Array',
'Function',
@@ -134,10 +135,15 @@ primordials.SafePromise = makeSafe(
'Map',
'Number',
'Object',
'RangeError',
'ReferenceError',
'RegExp',
'Set',
'String',
'Symbol',
'SyntaxError',
'TypeError',
'URIError',
'Uint16Array',
'Uint32Array',
'Uint8Array',
+1
View File
@@ -9,6 +9,7 @@ const {
ObjectSetPrototypeOf,
SafePromise,
Symbol,
TypeError,
WeakMap,
} = primordials;
+3 -1
View File
@@ -60,6 +60,8 @@ const {
Set,
StringPrototypeIncludes,
Symbol,
SyntaxError,
SyntaxErrorPrototype,
WeakSet,
} = primordials;
@@ -1566,7 +1568,7 @@ function defineDefaultCommands(repl) {
function Recoverable(err) {
this.err = err;
}
ObjectSetPrototypeOf(Recoverable.prototype, SyntaxError.prototype);
ObjectSetPrototypeOf(Recoverable.prototype, SyntaxErrorPrototype);
ObjectSetPrototypeOf(Recoverable, SyntaxError);
module.exports = {