File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
packages/ums-sdk/src/utils Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ describe('file-utils', () => {
3030 expect ( isFileNotFoundError ( error ) ) . toBe ( false ) ;
3131 } ) ;
3232
33+ it ( 'should return false for errors with non-string code property' , ( ) => {
34+ const error = Object . assign ( new Error ( 'Error' ) , { code : 123 } ) ;
35+ expect ( isFileNotFoundError ( error ) ) . toBe ( false ) ;
36+ } ) ;
37+
3338 it ( 'should return false for null' , ( ) => {
3439 expect ( isFileNotFoundError ( null ) ) . toBe ( false ) ;
3540 } ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,12 @@ import { ModuleNotFoundError } from '../errors/index.js';
99 * Type guard to check if an error is a NodeJS ErrnoException
1010 */
1111function isNodeError ( error : unknown ) : error is NodeJS . ErrnoException {
12- return error !== null && typeof error === 'object' && 'code' in error ;
12+ return (
13+ error !== null &&
14+ typeof error === 'object' &&
15+ 'code' in error &&
16+ typeof ( error as { code : unknown } ) . code === 'string'
17+ ) ;
1318}
1419
1520/**
You can’t perform that action at this time.
0 commit comments