fix(thread): 在线程外调用api.id时添加错误检查

添加对current变量的检查,防止在线程外调用api.id时导致空指针异常
This commit is contained in:
2025-09-01 17:24:28 +08:00
parent 4256803084
commit bd4b606a8a

View File

@@ -103,6 +103,9 @@ function api.exists(id)
end
function api.id()
if not current then
error("No current thread - are you calling this outside a thread?")
end
return current.id
end