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:
Ruben Bridgewater 2018-04-07 14:20:43 +02:00
parent 362694401f
commit 252eb2deb2
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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'
} }
); );