fix(utils): pcall protect `do_or_fail`
This commit is contained in:
parent
11d93536b9
commit
b08528a710
|
@ -58,9 +58,9 @@ end
|
|||
-- At some point, we should probably write a wrapper to make penlight's function work with pcalls.
|
||||
function utils.do_or_fail<T>(func: function<T>(...: any): (T | nil, string), ...: any): T
|
||||
local log = require "logger"
|
||||
local res, err = func(...)
|
||||
local ok, res, err = pcall(func, ...)
|
||||
|
||||
if not res then
|
||||
if not (ok and res) then
|
||||
log:error { "do_or_fail failed!", error = err }
|
||||
error(err)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue