lua-users home
lua-l archive

Re: How to ignore module not found

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Dan
I tried wrapping it in pcall, but that didn't work.
It does work. How did you do it?
-- not tested! --
-- local opt = require("optionalmod")
local ok, opt = pcall (require, "optionalmod")
if ok then
 -- opt is the module
else
 -- opt is the error message
end
Regards,
Tomás

AltStyle によって変換されたページ (->オリジナル) /