Merge pull request #3421 from myk002/myk_json

don't throw if json is unreadable
develop
Myk 2023-05-24 17:20:35 -07:00 committed by GitHub
commit a2f0a98067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 ## Misc Improvements
- `autodump`: no longer checks for a keyboard cursor before executing, so ``autodump destroy`` (which doesn't require a cursor) can still function - `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 - `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 - 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") - `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 end
else else
self.exists = true 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 end
return self.data return self.data
end end