summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-06 00:48:14 +0800
committerruki <[email protected]>2025-12-06 00:48:14 +0800
commitcd1323f4590b51b092da2c69d44853e1185e3c40 (patch)
tree92c07602a275e956454b448b5da12ba92655bb12 /core/src
parent741f72574321240b53076d30abd939f28f8287cc (diff)
improve hash error
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/hash/md5.c7
-rw-r--r--core/src/xmake/hash/sha.c7
-rw-r--r--core/src/xmake/hash/xxhash.c7
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;
}