don't throw if json is unreadable

just act like the file didn't exist (unless strict is set)
develop
Myk Taylor 2023-05-24 12:41:02 -07:00
parent 44340dfb75
commit 87775317a5
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 8 additions and 1 deletions

@ -51,6 +51,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Misc Improvements
- `autodump`: no longer checks for a keyboard cursor before executing, so ``autodump destroy`` (which doesn't require a cursor) can still function
- Settings: recover gracefully when settings files become corrupted (e.g. by CTD)
- `orders`: update orders in orders library for prepared meals, bins, archer uniforms, and weapons
- Terminal console no longer appears in front of the game window on startup
- `gui/control-panel`: new preference for whether filters in lists search for substrings in the middle of words (e.g. if set to true, then "ee" will match "steel")

@ -59,7 +59,13 @@ function _file:read(strict)
end
else
self.exists = true
self.data = decode_file(self.path)
local ok, err = pcall(function() self.data = decode_file(self.path) end)
if not ok then
if strict then
error(('cannot decode file: %s: %s'):format(self.path, err))
end
self.data = {}
end
end
return self.data
end