fix(utils): pcall protect `do_or_fail`
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details

This commit is contained in:
Aire-One 2022-10-22 15:04:21 +02:00
parent 11d93536b9
commit b08528a710
1 changed files with 2 additions and 2 deletions

View File

@ -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