commit 58ba36e539b4981ba0454d58c0dad8e3a54affa9
parent ae719ebcfddd5a2805e838507b364a40dbd01c15
Author: Frederic Cambus <fred@statdns.com>
Date: Sat, 5 Mar 2016 18:15:01 +0100
Adding error checking for the readFile and writeFile functions
Diffstat:
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/TODO b/TODO
@@ -1,3 +1,2 @@
-- Implement error checking everywhere
- Publish on Luarocks
- Add support for plugins
diff --git a/motyl.lua b/motyl.lua
@@ -21,7 +21,7 @@ local lustache = require "lustache"
local markdown = require "markdown"
local function readFile(path)
- local file = io.open(path, "rb")
+ local file = assert(io.open(path, "rb"))
local content = file:read "*all"
file:close()
@@ -30,7 +30,7 @@ local function readFile(path)
end
local function writeFile(path, data)
- local file = io.open(path, "wb")
+ local file = assert(io.open(path, "wb"))
file:write(data)
file:close()