local function method_with_error(level)
local ok, err = pcall(function()
error("test exception", 0)
end)
if not ok then
-- Any partial processing here,
-- then send the error on
error(err, level)
end
end
-- Level 0: the error goes on as it is
local _, msg = pcall(method_with_error, 0)
-- msg = test exception
-- The default level adds a position to the text
local _, with_position = pcall(method_with_error)
-- with_position = main.lua:8: test exception
print("msg = " .. msg)
print("with_position = " .. with_position)