MicroController/stdlib/core.lua

17 lines
362 B
Lua
Raw Permalink Normal View History

2019-03-05 19:50:21 +08:00
--- Core module
-- @module Core
--- Errors if the variable evaluates to false, with an optional msg
-- @param var variable to evaluate
-- @param msg (optional) message
function fail_if_missing(var, msg)
if not var then
if msg then
error(msg, 3)
else
error("Missing value", 3)
end
end
return false
end