Skip to content

Commit

Permalink
lib: added isNativeError check to assert.js
Browse files Browse the repository at this point in the history
Added the function for compliance with
frameworks such as Jest

Fixes: nodejs#50780
  • Loading branch information
NiharPhansalkar committed Dec 21, 2023
1 parent fe918f5 commit eaa8cd5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const {
validateFunction,
} = require('internal/validators');
const { fileURLToPath } = require('internal/url');
const { isNativeError } = internalBinding('types');

let isDeepEqual;
let isDeepStrictEqual;
Expand Down Expand Up @@ -393,6 +394,8 @@ function innerOk(fn, argLen, value, message) {
} else if (message == null) {
generatedMessage = true;
message = getErrMessage(message, fn);
} else if (isNativeError(message)) {
throw message;
} else if (message instanceof Error) {
throw message;
}
Expand Down

0 comments on commit eaa8cd5

Please sign in to comment.