Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: continue script on parse error #46

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions resource/server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ AddEventHandler('onResourceStart', function(name)
end

for i = 1, #Config.ELSFiles do
local data = LoadResourceFile(GetCurrentResourceName(), 'xmlFiles/' .. Config.ELSFiles[i])

if data then ParseObjSet(data, Config.ELSFiles[i])
else print('VCF file not found: ' .. Config.ELSFiles[i]) end
local file = Config.ELSFiles[i]
local data = LoadResourceFile(GetCurrentResourceName(), 'xmlFiles/' .. file)

if data then
if pcall(function() ParseObjSet(data, file) end) then
-- no errors
print('Parsed VCF for: ' .. file)
else
-- VCF is faulty, notify the user and continue
print('VCF file ' .. file .. ' could not be parsed: is your XML valid?')
end
else
print('VCF file ' .. file .. ' not found: does the file exist?')
end
end

-- send the ELS data to all clients
Expand Down
2 changes: 0 additions & 2 deletions resource/server/parseVCF.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,4 @@ function ParseVCF(xml, fileName)
end

kjxmlData[fileName] = vcf

print('ELS: Parsed VCF for ' .. fileName)
end