fix(utils): `do_or_fail` `res` need to be promoted

This commit is contained in:
Aire-One 2023-01-21 21:01:42 +01:00
parent 4be2a48609
commit 418c86e23b
1 changed files with 2 additions and 2 deletions

View File

@ -58,12 +58,12 @@ function utils.do_or_fail<T>(func: function<T>(...: any): (T | nil, string), ...
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 }))
error(err)
end
return res
return res as T -- promote to T since pcall succeeded at this point
end
return utils