LUA 异常抛出与捕获

--1、使用pcall
local ok ,e = pcall(function()
   error{5} 
end)
if not ok then
    print(unpack(e))
end

--2、使用xpcall
xpcall(function()
    error(5,0)
end,
function(e)
    print(e)
end)

--阻止控制台关闭
os.execute 'pause'

猜你喜欢

转载自blog.csdn.net/cuijiahao/article/details/83115456