Skip to content

Commit

Permalink
Improve error handling for MacOS in require.lua (#1190)
Browse files Browse the repository at this point in the history
Sometimes when package.loadlib fails to load a library, it returns nil, so we should display its second and third returned values that may contain more error information.
  • Loading branch information
Not-A-Normal-Robot authored Dec 28, 2024
1 parent 2228b9d commit eee7ceb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Zframework/require.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ return function(libName)
return
end
if SYSTEM=='macOS' then
require=package.loadlib(libName..'.dylib','luaopen_'..libName)
success,res=pcall(require)
local a,b,c=package.loadlib(libName..'.dylib','luaopen_'..libName)
require=a

if require then
success,res=pcall(require)
else
success,res=false,'package.loadlib returned nil, along with:\n[2]:\n'..b..'[3]:\n'..c
end
else
if SYSTEM=='Android' and not loaded[libName] then
local platform=(function()
Expand Down

0 comments on commit eee7ceb

Please sign in to comment.