From e6651171bfb19404376cbf2ed6d4a0afd046cccb Mon Sep 17 00:00:00 2001 From: lethosor Date: Mon, 25 Dec 2017 14:40:06 -0500 Subject: [PATCH] json: Improve IO-related error messages --- library/lua/json.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/lua/json.lua b/library/lua/json.lua index ac7aa6327..2b4b3a66a 100644 --- a/library/lua/json.lua +++ b/library/lua/json.lua @@ -21,6 +21,9 @@ function encode_file(data, path, ...) end local contents = encode(data, ...) local f = io.open(path, 'w') + if not f then + error('Could not write to ' .. tostring(path)) + end f:write(contents) f:close() end @@ -32,7 +35,7 @@ end function decode_file(path, ...) local f = io.open(path) if not f then - error('Could not open ' .. path) + error('Could not read from ' .. tostring(path)) end local contents = f:read('*all') f:close()