blob: 4183610d12d1a0a147bbd8676e6d7c403f11056b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
local _anon_func_0 = function(error)
return error("boom")
end
local _anon_func_1 = function(e, error)
return error("wrap:" .. e:match("^.-:%d+:%s*(.*)$"))
end
return describe("try/catch", function()
return it("catch and rethrow", function()
local pcall <const> = pcall
local error <const> = error
local xpcall <const> = xpcall
local assert <const> = assert
local ok, success, err = pcall(function()
return xpcall(_anon_func_0, function(e)
local _, result = pcall(_anon_func_1, e, error)
return result
end, error)
end)
assert.same(ok, true)
assert.same(success, false)
return assert.is_true(err:match("wrap:boom") ~= nil)
end)
end)
|