mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
errors: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36167 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ const {
|
||||
String,
|
||||
StringPrototypeEndsWith,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeMatch,
|
||||
StringPrototypeSlice,
|
||||
StringPrototypeSplit,
|
||||
StringPrototypeStartsWith,
|
||||
@@ -96,7 +97,7 @@ const prepareStackTrace = (globalThis, error, trace) => {
|
||||
if (trace.length === 0) {
|
||||
return errorString;
|
||||
}
|
||||
return `${errorString}\n at ${trace.join('\n at ')}`;
|
||||
return `${errorString}\n at ${ArrayPrototypeJoin(trace, '\n at ')}`;
|
||||
};
|
||||
|
||||
const maybeOverridePrepareStackTrace = (globalThis, error, trace) => {
|
||||
@@ -376,10 +377,11 @@ function getMessage(key, args, self) {
|
||||
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
||||
`match the required ones (${msg.length}).`
|
||||
);
|
||||
return msg.apply(self, args);
|
||||
return ReflectApply(msg, self, args);
|
||||
}
|
||||
|
||||
const expectedLength = (msg.match(/%[dfijoOs]/g) || []).length;
|
||||
const expectedLength =
|
||||
(StringPrototypeMatch(msg, /%[dfijoOs]/g) || []).length;
|
||||
assert(
|
||||
expectedLength === args.length,
|
||||
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
|
||||
|
||||
@@ -9,7 +9,7 @@ assert.throws(
|
||||
() => { new SystemError(); },
|
||||
{
|
||||
name: 'TypeError',
|
||||
message: 'Cannot read property \'match\' of undefined'
|
||||
message: 'String.prototype.match called on null or undefined'
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user