[Misc] Add vmf.catch_errors
This commit is contained in:
parent
e83c3d893b
commit
0b7af2d48b
1 changed files with 10 additions and 0 deletions
|
@ -19,6 +19,16 @@ function vmf.check_wrong_argument_type(mod, vmf_function_name, argument_name, ar
|
|||
return true
|
||||
end
|
||||
|
||||
|
||||
function vmf.throw_error(error_message, ...)
|
||||
error(string.format(error_message, ...), 0)
|
||||
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
|
Loading…
Add table
Reference in a new issue