Skip to content

Commit 08cb122

Browse files
authored
chore: always print generated code in DEBUG mode (#29)
1 parent ab6ac2f commit 08cb122

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/jsonschema.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,24 +226,27 @@ end
226226
function codectx_mt:as_func(name, ...)
227227
self:_get_loader()
228228
local loader, err = loadstring(tab_concat(self._code_table, ""), 'jsonschema:' .. (name or 'anonymous'))
229-
if loader then
230-
local validator
231-
validator, err = loader(self._uservalues, ...)
232-
if validator then return validator end
233-
end
234-
235-
-- something went really wrong
236229
if DEBUG then
237230
local line=1
238231
print('------------------------------')
239-
print('FAILED to generate validator: ', err)
240232
print('generated code:')
241233
print('0001: ' .. self:as_string():gsub('\n', function()
242234
line = line + 1
243235
return sformat('\n%04d: ', line)
244236
end))
245237
print('------------------------------')
246238
end
239+
240+
if loader then
241+
local validator
242+
validator, err = loader(self._uservalues, ...)
243+
if validator then return validator end
244+
end
245+
246+
-- something went really wrong
247+
if DEBUG then
248+
print('FAILED to generate validator: ', err)
249+
end
247250
error(err)
248251
end
249252

0 commit comments

Comments
 (0)