assert: fix error message
`assert.throws` also accepts objects and errors as input. This fixes the error message accodingly. PR-URL: https://github.com/nodejs/node/pull/19865 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
362694401f
commit
252eb2deb2
@ -465,7 +465,9 @@ async function waitForActual(block) {
|
|||||||
function expectsError(stackStartFn, actual, error, message) {
|
function expectsError(stackStartFn, actual, error, message) {
|
||||||
if (typeof error === 'string') {
|
if (typeof error === 'string') {
|
||||||
if (arguments.length === 4) {
|
if (arguments.length === 4) {
|
||||||
throw new ERR_INVALID_ARG_TYPE('error', ['Function', 'RegExp'], error);
|
throw new ERR_INVALID_ARG_TYPE('error',
|
||||||
|
['Object', 'Error', 'Function', 'RegExp'],
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
message = error;
|
message = error;
|
||||||
error = null;
|
error = null;
|
||||||
|
@ -741,8 +741,8 @@ common.expectsError(
|
|||||||
{
|
{
|
||||||
code: 'ERR_INVALID_ARG_TYPE',
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
type: TypeError,
|
type: TypeError,
|
||||||
message: 'The "error" argument must be one of type Function or RegExp. ' +
|
message: 'The "error" argument must be one of type Object, Error, ' +
|
||||||
'Received type string'
|
'Function, or RegExp. Received type string'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user