Commit fa191806 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

report JSON file name on parse error

parent b257cb57
......@@ -74,13 +74,21 @@ end
function PolicySet:loadJSON(name, fname)
local file = fname and or open(name, self.importdirs)
local file
if fname then
file =
file, fname = open(name, self.importdirs)
if not file then error('Import failed: ' end
local data = ''
for line in file:lines() do data = data..line end
return json.decode(data)
local success, res = pcall(json.decode, data)
if success then return res end
error(res..' while parsing '..fname)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment