Skip to content
Merged
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
8 changes: 5 additions & 3 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const {
String,
StringPrototypeEndsWith,
StringPrototypeIncludes,
StringPrototypeMatch,
StringPrototypeSlice,
StringPrototypeSplit,
StringPrototypeStartsWith,
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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 ` +
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-errors-systemerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
);

Expand Down