Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: enhance use of Error from primordials #31163

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ rules:
message: "Use `const { Reflect } = primordials;` instead of the global."
- name: Symbol
message: "Use `const { Symbol } = primordials;` instead of the global."
- name: Error
message: "Use `const { Error } = primordials;` instead of the global."
no-restricted-syntax:
# Config copied from .eslintrc.js
- error
Expand Down
1 change: 1 addition & 0 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
ArrayIsArray,
Boolean,
Error,
NumberIsFinite,
ObjectAssign,
ObjectKeys,
Expand Down
1 change: 1 addition & 0 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'use strict';

const {
Error,
ObjectKeys,
ObjectSetPrototypeOf,
Symbol,
Expand Down
1 change: 1 addition & 0 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'use strict';

const {
Error,
ObjectAssign,
ObjectIs,
ObjectKeys,
Expand Down
1 change: 1 addition & 0 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
Array,
ArrayIsArray,
Error,
MathFloor,
MathMin,
MathTrunc,
Expand Down
1 change: 1 addition & 0 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const {
ArrayIsArray,
Error,
NumberIsInteger,
ObjectAssign,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

const {
Array,
Error,
ObjectDefineProperty,
ReflectApply,
Symbol,
Expand Down
1 change: 1 addition & 0 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
Array,
Boolean,
Error,
MathMin,
NumberIsNaN,
ObjectCreate,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/assert/assertion_error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
Error,
MathMax,
ObjectCreate,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
Error,
FunctionPrototypeBind,
NumberIsSafeInteger,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/bootstrap/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/* global process, getLinkedBinding, getInternalBinding, primordials */

const {
Error,
ReflectGet,
ObjectCreate,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
ArrayFrom,
ArrayIsArray,
Boolean,
Error,
MathFloor,
Number,
ObjectDefineProperties,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/error-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Buffer = require('buffer').Buffer;
const {
ArrayPrototypeForEach,
Error,
FunctionPrototypeCall,
ObjectAssign,
ObjectCreate,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

const {
ArrayIsArray,
Error,
MathAbs,
NumberIsInteger,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ArrayIsArray,
BigInt,
DateNow,
Error,
Number,
NumberIsFinite,
ObjectSetPrototypeOf,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ArrayIsArray,
Error,
MathMax,
Number,
ObjectCreate,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const {
ArrayIsArray,
Error,
JSONParse,
ObjectCreate,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/per_context/domexception.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
Error,
ObjectDefineProperties,
ObjectDefineProperty,
SafeWeakMap,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/process/promises.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const {
Error,
ObjectDefineProperty,
} = primordials;

Expand Down
1 change: 1 addition & 0 deletions lib/internal/process/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const {
ArrayIsArray,
Error,
} = primordials;

const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/source_map/prepare_stack_trace.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

const {
Error,
} = primordials;

const debug = require('internal/util/debuglog').debuglog('source_map');
const { findSourceMap } = require('internal/source_map/source_map_cache');
const { overrideStackTrace } = require('internal/errors');
Expand Down
1 change: 1 addition & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const {
ArrayFrom,
ArrayIsArray,
Error,
ObjectCreate,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
BigIntPrototypeValueOf,
BooleanPrototypeValueOf,
DatePrototypeGetTime,
Error,
NumberIsNaN,
NumberPrototypeValueOf,
ObjectGetOwnPropertySymbols,
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/v8_prof_polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/* eslint-disable no-restricted-globals */

module.exports = { versionCheck };

// Don't execute when required directly instead of being eval'd from
Expand Down
1 change: 1 addition & 0 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
const {
ArrayIsArray,
Boolean,
Error,
Number,
NumberIsNaN,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'use strict';

const {
Error,
MathMax,
NumberIsNaN,
ObjectAssign,
Expand Down
1 change: 1 addition & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

const {
ArrayIsArray,
Error,
NumberIsSafeInteger,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down
1 change: 1 addition & 0 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
const {
Array,
ArrayBuffer,
Error,
Float32Array,
Float64Array,
Int16Array,
Expand Down
1 change: 1 addition & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
'use strict';

const {
Error,
MathMax,
NumberIsFinite,
NumberIsNaN,
Expand Down