Skip to content
Merged
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
19 changes: 11 additions & 8 deletions lib/jsonschema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,27 @@ end
function codectx_mt:as_func(name, ...)
self:_get_loader()
local loader, err = loadstring(tab_concat(self._code_table, ""), 'jsonschema:' .. (name or 'anonymous'))
if loader then
local validator
validator, err = loader(self._uservalues, ...)
if validator then return validator end
end

-- something went really wrong
if DEBUG then
local line=1
print('------------------------------')
print('FAILED to generate validator: ', err)
print('generated code:')
print('0001: ' .. self:as_string():gsub('\n', function()
line = line + 1
return sformat('\n%04d: ', line)
end))
print('------------------------------')
end

if loader then
local validator
validator, err = loader(self._uservalues, ...)
if validator then return validator end
end

-- something went really wrong
if DEBUG then
print('FAILED to generate validator: ', err)
end
error(err)
end

Expand Down