Add assertions for dumpLoveFile and loadLoveFile (#11)

This will print useful error messages instead of just failing silently.

E.g.:
`lib/Bitser.lua:370: Could not open file prabs/test.lua. Does not exist.`
This commit is contained in:
Robert Machmer 2018-02-20 18:38:47 +01:00 committed by Robin Wellner
parent dd3034117f
commit 4f2680317c

View File

@ -364,9 +364,10 @@ return {dumps = function(value)
return ffi.string(buf, buf_pos)
end, dumpLoveFile = function(fname, value)
serialize(value)
love.filesystem.write(fname, ffi.string(buf, buf_pos))
assert(love.filesystem.write(fname, ffi.string(buf, buf_pos)))
end, loadLoveFile = function(fname)
local serializedData = love.filesystem.newFileData(fname)
local serializedData, error = love.filesystem.newFileData(fname)
assert(serializedData, error)
Buffer_newDataReader(serializedData:getPointer(), serializedData:getSize())
return deserialize_value({})
end, loadData = function(data, size)