fix(utils): `do_or_fail` `res` need to be promoted
This commit is contained in:
parent
4be2a48609
commit
418c86e23b
|
@ -58,12 +58,12 @@ function utils.do_or_fail<T>(func: function<T>(...: any): (T | nil, string), ...
|
||||||
|
|
||||||
local ok, res, err = pcall(func, ...)
|
local ok, res, err = pcall(func, ...)
|
||||||
|
|
||||||
if not (ok and res) then
|
if not ok then
|
||||||
log:error(logger.message_with_metadata("do_or_fail failed!", { error = err }))
|
log:error(logger.message_with_metadata("do_or_fail failed!", { error = err }))
|
||||||
error(err)
|
error(err)
|
||||||
end
|
end
|
||||||
|
|
||||||
return res
|
return res as T -- promote to T since pcall succeeded at this point
|
||||||
end
|
end
|
||||||
|
|
||||||
return utils
|
return utils
|
||||||
|
|
Loading…
Reference in New Issue