diff options
-rw-r--r-- | provisioning-model.lua | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/provisioning-model.lua b/provisioning-model.lua index bb68af6..8a24545 100644 --- a/provisioning-model.lua +++ b/provisioning-model.lua @@ -246,8 +246,14 @@ validateparamcoded = function(p, top) setfenv (0, env) local f = loadstring(p.validate) if (f) then - p.value, p.errtxt = f(p.value, functions, top) - if p.errtxt then success = false end + local res, err = pcall(function() + p.value, p.errtxt = f(p.value, functions, top) + if p.errtxt then success = false end + end) + if not res and err then + success = false + p.errtxt = "Exception in validate code\n"..err + end end setfenv (0, _G) end @@ -261,7 +267,14 @@ local function callscript(script, ...) -- so we set env 0, not env 1 setfenv (0, env) local f = loadfile(script) - if (f) then f(functions, ...) end + if f then + local res, err = pcall(function(...) + f(functions, ...) + end, ...) + if not res and err then + assert(res, "Update Successful\nException in post update script\n"..err) + end + end setfenv (0, _G) end |