Skip to content

Commit 6af8390

Browse files
committed
fix: add file existence check and improve error logging
- Add FileExists check to prevent runtime errors on missing files - Add detailed error logging when file read operations fail
1 parent 9e1b35e commit 6af8390

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mConfigFromFile.axs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,20 @@ define_function GetConfig(char path[]) {
100100
return
101101
}
102102

103+
// Check if file exists
104+
if (!NAVFileExists(path)) {
105+
NAVLog("'mConfigFromFile => File does not exist at path: ', path")
106+
return
107+
}
108+
103109
result = NAVFileRead(path, data)
104110

105111
if (result <= 0) {
112+
NAVLog("'mConfigFromFile => File read failed for path: ', path, ' (Error: ', NAVGetFileError(result), ')'")
106113
return
107114
}
108115

116+
// If read was successful, the result is the total bytes read
109117
total = type_cast(result)
110118

111119
NAVLog("'mConfigFromFile => Total Bytes Read: ', itoa(total)")

0 commit comments

Comments
 (0)