diff --git a/tools.lua b/tools.lua index 54a9801..749e176 100644 --- a/tools.lua +++ b/tools.lua @@ -72,7 +72,7 @@ function tools.req(url, par, f, dbg) if fr then par[ft] = { filename = fn, - data = fr:read '*a' + data = fr:read '*a' } fr:close() else par[ft] = fn end @@ -84,8 +84,8 @@ function tools.req(url, par, f, dbg) if dbg then print(url, succ, res, par) -- dump(par)) end - res = json.decode(res or '{}') - if not succ or not res then return {}, false end + local s, res = pcall(json.decode, res or '{}') + if not s or not succ or not res then return {}, false end return res, true end