RosettaCodeData/Task/Exceptions/Lua/exceptions-3.lua

11 lines
292 B
Lua
Raw Permalink Normal View History

2025-08-11 18:05:26 -07:00
function throw_error_with_arg(arg)
error(string.format("Whoops! argument = %s", arg))
2023-07-01 11:58:00 -04:00
-- won't ever appear, due to previous error() call
return "hello!"
end
2025-08-11 18:05:26 -07:00
local status, errmsg = pcall(throw_error_with_arg, "foobar 123")
if (status ~= 0) then
print("errmsg = ", errmsg)
end