aboutsummaryrefslogtreecommitdiff
path: root/lib/internal/errors.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/errors.js')
-rw-r--r--lib/internal/errors.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index 6d4a582631..a5155d936b 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -10,7 +10,11 @@
// value statically and permanently identifies the error. While the error
// message may change, the code should not.
-const { Object, Math } = primordials;
+const {
+ MathAbs,
+ ObjectDefineProperty,
+ ObjectKeys,
+} = primordials;
const messages = new Map();
const codes = {};
@@ -113,7 +117,7 @@ class SystemError extends Error {
if (context.dest !== undefined)
message += ` => ${context.dest}`;
- Object.defineProperty(this, 'message', {
+ ObjectDefineProperty(this, 'message', {
value: message,
enumerable: false,
writable: true,
@@ -123,14 +127,14 @@ class SystemError extends Error {
this.code = key;
- Object.defineProperty(this, 'info', {
+ ObjectDefineProperty(this, 'info', {
value: context,
enumerable: true,
configurable: true,
writable: false
});
- Object.defineProperty(this, 'errno', {
+ ObjectDefineProperty(this, 'errno', {
get() {
return context.errno;
},
@@ -141,7 +145,7 @@ class SystemError extends Error {
configurable: true
});
- Object.defineProperty(this, 'syscall', {
+ ObjectDefineProperty(this, 'syscall', {
get() {
return context.syscall;
},
@@ -158,7 +162,7 @@ class SystemError extends Error {
// always be of type string. We should probably just remove the
// `.toString()` and `Buffer.from()` operations and set the value on the
// context as the user did.
- Object.defineProperty(this, 'path', {
+ ObjectDefineProperty(this, 'path', {
get() {
return context.path != null ?
context.path.toString() : context.path;
@@ -173,7 +177,7 @@ class SystemError extends Error {
}
if (context.dest !== undefined) {
- Object.defineProperty(this, 'dest', {
+ ObjectDefineProperty(this, 'dest', {
get() {
return context.dest != null ?
context.dest.toString() : context.dest;
@@ -222,7 +226,7 @@ function makeNodeErrorWithCode(Base, key) {
Error.stackTraceLimit = limit;
}
const message = getMessage(key, args, this);
- Object.defineProperty(this, 'message', {
+ ObjectDefineProperty(this, 'message', {
value: message,
enumerable: false,
writable: true,
@@ -270,7 +274,7 @@ function addCodeToName(err, name, code) {
err.stack;
// Reset the name to the actual name.
if (name === 'SystemError') {
- Object.defineProperty(err, 'name', {
+ ObjectDefineProperty(err, 'name', {
value: name,
enumerable: false,
writable: true,
@@ -383,7 +387,7 @@ function uvException(ctx) {
const err = new Error(message);
Error.stackTraceLimit = tmpLimit;
- for (const prop of Object.keys(ctx)) {
+ for (const prop of ObjectKeys(ctx)) {
if (prop === 'message' || prop === 'path' || prop === 'dest') {
continue;
}
@@ -1103,7 +1107,7 @@ E('ERR_OUT_OF_RANGE',
let msg = replaceDefaultBoolean ? str :
`The value of "${str}" is out of range.`;
let received;
- if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
+ if (Number.isInteger(input) && MathAbs(input) > 2 ** 32) {
received = addNumericalSeparator(String(input));
} else if (typeof input === 'bigint') {
received = String(input);