Skip to content

Commit

Permalink
Use util.types.isNativeError()
Browse files Browse the repository at this point in the history
  • Loading branch information
novemberborn committed Dec 31, 2021
1 parent af29824 commit acd0dd9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import util from 'node:util';

import concordance from 'concordance';
import isPromise from 'is-promise';

Expand Down Expand Up @@ -153,7 +155,7 @@ function validateExpectations(assertion, expectations, numberArgs) { // eslint-d
// Note: this function *must* throw exceptions, since it can be used
// as part of a pending assertion for promises.
function assertExpectations({assertion, actual, expectations, message, prefix, savedError}) {
if (!(actual instanceof Error)) {
if (!util.types.isNativeError(actual)) {
throw new AssertionError({
assertion,
message,
Expand Down
3 changes: 2 additions & 1 deletion lib/serialize-error.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import process from 'node:process';
import {fileURLToPath, pathToFileURL} from 'node:url';
import util from 'node:util';

import cleanYamlObject from 'clean-yaml-object';
import concordance from 'concordance';
Expand Down Expand Up @@ -145,7 +146,7 @@ function trySerializeError(error, shouldBeautifyStack, testFile) {
}

export default function serializeError(origin, shouldBeautifyStack, error, testFile) {
if (!(error instanceof Error)) {
if (!util.types.isNativeError(error)) {
return {
avaAssertionError: false,
nonErrorObject: true,
Expand Down

0 comments on commit acd0dd9

Please sign in to comment.