@@ -192,7 +192,10 @@ export function parseVersionNum(versionNum: string): { major: string; minor: str
192192 major : Math . floor ( num / 10000 ) . toString ( ) ,
193193 minor : ( num % 10000 ) . toString ( ) ,
194194 } ;
195- } catch {
195+ } catch ( err ) {
196+ // parseInt shouldn't throw, but handle edge cases defensively
197+ const errorMsg = err instanceof Error ? err . message : String ( err ) ;
198+ console . log ( `[parseVersionNum] Warning: Failed to parse "${ versionNum } ": ${ errorMsg } ` ) ;
196199 return { major : "" , minor : "" } ;
197200 }
198201}
@@ -718,6 +721,8 @@ function readTextFileSafe(p: string): string | null {
718721 const value = fs . readFileSync ( p , "utf8" ) . trim ( ) ;
719722 return value || null ;
720723 } catch {
724+ // Intentionally silent: this is a "safe" read that returns null on any error
725+ // (file not found, permission denied, etc.) - used for optional config files
721726 return null ;
722727 }
723728}
@@ -737,16 +742,25 @@ function resolveBuildTs(): string | null {
737742 const pkgRoot = path . resolve ( __dirname , ".." ) ;
738743 const fromPkgFile = readTextFileSafe ( path . join ( pkgRoot , "BUILD_TS" ) ) ;
739744 if ( fromPkgFile ) return fromPkgFile ;
740- } catch {
741- // ignore
745+ } catch ( err ) {
746+ // Path resolution failed (rare) - fall through to next fallback
747+ if ( process . env . DEBUG ) {
748+ const errorMsg = err instanceof Error ? err . message : String ( err ) ;
749+ console . log ( `[resolveBuildTs] Path resolution failed: ${ errorMsg } ` ) ;
750+ }
742751 }
743752
744753 // Last resort: use package.json mtime as an approximation (non-null, stable-ish).
745754 try {
746755 const pkgJsonPath = path . resolve ( __dirname , ".." , "package.json" ) ;
747756 const st = fs . statSync ( pkgJsonPath ) ;
748757 return st . mtime . toISOString ( ) ;
749- } catch {
758+ } catch ( err ) {
759+ // package.json not found or inaccessible - use current time
760+ if ( process . env . DEBUG ) {
761+ const errorMsg = err instanceof Error ? err . message : String ( err ) ;
762+ console . log ( `[resolveBuildTs] Could not stat package.json: ${ errorMsg } ` ) ;
763+ }
750764 return new Date ( ) . toISOString ( ) ;
751765 }
752766}
0 commit comments