Skip to content

Commit

Permalink
log errors when writing to save file
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Mar 14, 2020
1 parent 95f58b0 commit e34b3e0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lua/save.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ function am.save_state(name, state, format)
elseif am.platform == "ios" then
am.ios_store_pref(name, str)
else
local f = io.open(am.app_data_dir..name..".sav", "w")
f:write(str)
f:close()
local filename = am.app_data_dir..name..".sav"
local f, err = io.open(filename, "w")
if f then
f:write(str)
f:close()
else
log("error opening '%s'\n%s", filename, tostring(err))
end
end
end

Expand Down

0 comments on commit e34b3e0

Please sign in to comment.