Skip to content

Commit

Permalink
assert: fix error message
Browse files Browse the repository at this point in the history
`assert.throws` also accepts objects and errors as input. This fixes
the error message accodingly.

PR-URL: #19865
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
BridgeAR committed Apr 9, 2018
1 parent 3626944 commit 252eb2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ async function waitForActual(block) {
function expectsError(stackStartFn, actual, error, message) {
if (typeof error === 'string') {
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;
error = null;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ common.expectsError(
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "error" argument must be one of type Function or RegExp. ' +
'Received type string'
message: 'The "error" argument must be one of type Object, Error, ' +
'Function, or RegExp. Received type string'
}
);

Expand Down

0 comments on commit 252eb2d

Please sign in to comment.