I tried to use
http://keplerproject.github.io/luafilesystem/examples.html< br>and it throws an error on the inaccessible directory.
This seems to be caused by luaL_error https://github.com/keplerproject/luafilesystem/blob/master/src/lfs.c#L563
How can I catch this error?
http://www.tutorialspoint.com/lua/lua_error_handling.htm
Pcall is recommended, but this will not prevent the script from dying:
pcall(lfs. dir('/etc/passwd')) #this fails to handle the not a directory error
local ok, res = pcall(lfs.dir,'/etc/passwd')
Please note that the parameters passed to lfs.dir are for pcall, not lfs.dir.
I am new to lua.
I tried to use
http://keplerproject.github.io/luafilesystem/ examples.html
and it throws an error on an inaccessible directory.
This seems to be caused by luaL_error https://github.com/keplerproject/luafilesystem/blob/master/src/lfs.c #L563 caused
How can I catch this error?
http://www.tutorialspoint.com/lua/lua_error_handling.htm
Pcall is recommended, but this will not prevent the script from dying:
pcall(lfs. dir('/etc/passwd')) #this fails to handle the not a directory error
pcall(lfs.dir(‘/ etc / passwd’ )) failed because the error was triggered outside of pcall (when calculating the parameters of pcall). You need to use
local ok, res = pcall(lfs .dir,'/etc/passwd')
Please note that the parameters passed to lfs.dir are for pcall, not lfs.dir.
< /p>