local function throw_if_true(param)
local ok = pcall(function()
if param then
error("test exception", 0)
end
end)
if not ok then
print("except")
end
-- Нет finally: этот код стоит после pcall, поэтому выполняется и после
-- ошибки, и без неё
print("finally")
end
throw_if_true(true)
-- except
-- finally
throw_if_true(false)
-- finally