Skip to content

Commit

Permalink
fix: avoid instanceof Object check in isErrorLike (#8527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmydief committed Jun 17, 2022
1 parent f0c1737 commit 6cd5cd0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/util.ts
Expand Up @@ -407,7 +407,9 @@ interface ErrorLike extends Error {
}

export function isErrorLike(obj: unknown): obj is ErrorLike {
return obj instanceof Object && 'name' in obj && 'message' in obj;
return (
typeof obj === 'object' && obj !== null && 'name' in obj && 'message' in obj
);
}

export function isErrnoException(obj: unknown): obj is NodeJS.ErrnoException {
Expand Down

0 comments on commit 6cd5cd0

Please sign in to comment.