local function method_with_error(level)
local ok, err = pcall(function()
error("test exception", 0)
end)
if not ok then
-- Любая частичная обработка здесь,
-- затем ошибка идёт дальше
error(err, level)
end
end
-- Уровень 0: ошибка идёт дальше как есть
local _, msg = pcall(method_with_error, 0)
-- msg = test exception
-- Уровень по умолчанию добавляет к тексту позицию
local _, with_position = pcall(method_with_error)
-- with_position = main.lua:8: test exception
print("msg = " .. msg)
print("with_position = " .. with_position)