diff options
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/hash/md5.c | 7 | ||||
| -rw-r--r-- | core/src/xmake/hash/sha.c | 7 | ||||
| -rw-r--r-- | core/src/xmake/hash/xxhash.c | 7 |
3 files changed, 21 insertions, 0 deletions
diff --git a/core/src/xmake/hash/md5.c b/core/src/xmake/hash/md5.c index 56f68d99e..366d72951 100644 --- a/core/src/xmake/hash/md5.c +++ b/core/src/xmake/hash/md5.c @@ -115,6 +115,13 @@ tb_int_t xm_hash_md5(lua_State *lua) { } if (!ok) { lua_pushnil(lua); + // check if file exists to provide more specific error message + if (!tb_file_info(filename, tb_null)) { + lua_pushfstring(lua, "file not found: %s", filename); + } else { + lua_pushfstring(lua, "failed to read file: %s", filename); + } + return 2; } return 1; } diff --git a/core/src/xmake/hash/sha.c b/core/src/xmake/hash/sha.c index 8140c796c..c06307521 100644 --- a/core/src/xmake/hash/sha.c +++ b/core/src/xmake/hash/sha.c @@ -123,6 +123,13 @@ tb_int_t xm_hash_sha(lua_State *lua) { } if (!ok) { lua_pushnil(lua); + // check if file exists to provide more specific error message + if (!tb_file_info(filename, tb_null)) { + lua_pushfstring(lua, "file not found: %s", filename); + } else { + lua_pushfstring(lua, "failed to read file: %s", filename); + } + return 2; } return 1; } diff --git a/core/src/xmake/hash/xxhash.c b/core/src/xmake/hash/xxhash.c index bd40e47c7..77bf32dfe 100644 --- a/core/src/xmake/hash/xxhash.c +++ b/core/src/xmake/hash/xxhash.c @@ -174,6 +174,13 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { } if (!ok) { lua_pushnil(lua); + // check if file exists to provide more specific error message + if (!tb_file_info(filename, tb_null)) { + lua_pushfstring(lua, "file not found: %s", filename); + } else { + lua_pushfstring(lua, "failed to read file: %s", filename); + } + return 2; } return 1; } |
