--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'
--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'