[Misc] Add vmf.catch_errors

This commit is contained in:
Azumgi 2018-11-01 10:29:59 +03:00
parent e83c3d893b
commit 0b7af2d48b

View file

@ -19,6 +19,16 @@ function vmf.check_wrong_argument_type(mod, vmf_function_name, argument_name, ar
return true return true
end end
function vmf.throw_error(error_message, ...) function vmf.throw_error(error_message, ...)
error(string.format(error_message, ...), 0) error(string.format(error_message, ...), 0)
end end
function vmf.catch_errors(mod, error_format, exec_function, ...)
local success, error_message = pcall(exec_function, ...)
if not success then
mod:error(string.format(error_format, error_message))
return true
end
end