File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,13 @@ tb_int_t xm_hash_md5(lua_State *lua) {
115115 }
116116 if (!ok ) {
117117 lua_pushnil (lua );
118+ // check if file exists to provide more specific error message
119+ if (!tb_file_info (filename , tb_null )) {
120+ lua_pushfstring (lua , "file not found: %s" , filename );
121+ } else {
122+ lua_pushfstring (lua , "failed to read file: %s" , filename );
123+ }
124+ return 2 ;
118125 }
119126 return 1 ;
120127}
Original file line number Diff line number Diff line change @@ -123,6 +123,13 @@ tb_int_t xm_hash_sha(lua_State *lua) {
123123 }
124124 if (!ok ) {
125125 lua_pushnil (lua );
126+ // check if file exists to provide more specific error message
127+ if (!tb_file_info (filename , tb_null )) {
128+ lua_pushfstring (lua , "file not found: %s" , filename );
129+ } else {
130+ lua_pushfstring (lua , "failed to read file: %s" , filename );
131+ }
132+ return 2 ;
126133 }
127134 return 1 ;
128135}
Original file line number Diff line number Diff line change @@ -174,6 +174,13 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
174174 }
175175 if (!ok ) {
176176 lua_pushnil (lua );
177+ // check if file exists to provide more specific error message
178+ if (!tb_file_info (filename , tb_null )) {
179+ lua_pushfstring (lua , "file not found: %s" , filename );
180+ } else {
181+ lua_pushfstring (lua , "failed to read file: %s" , filename );
182+ }
183+ return 2 ;
177184 }
178185 return 1 ;
179186}
You can’t perform that action at this time.
0 commit comments