diff options
author | Ted Trask <ttrask01@yahoo.com> | 2011-06-09 07:10:28 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2011-06-09 07:10:28 +0000 |
commit | 89444d40a40b8bab0fe7f16cb6badb6d8bb061b4 (patch) | |
tree | 43565c2df9bc6e120e93a034e1861e2a12ebe6d8 | |
parent | 4512d2436bbb338900520cae66a762f9ab00d545 (diff) | |
download | acf-provisioning-89444d40a40b8bab0fe7f16cb6badb6d8bb061b4.tar.bz2 acf-provisioning-89444d40a40b8bab0fe7f16cb6badb6d8bb061b4.tar.xz |
Added better error processing for loaded Lua code
-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 |