diff options
author | mpeterv <mpeterval@gmail.com> | 2015-12-06 16:35:05 +0300 |
---|---|---|
committer | mpeterv <mpeterval@gmail.com> | 2015-12-06 16:41:01 +0300 |
commit | 7d2c47839afa38d5c521ca7377723d4fa8ccf9b2 (patch) | |
tree | c2be70ae4003caf112d751aac40758eb4351200b /src | |
parent | 03027b044896f0d4948f09c23a22ce19821d6cdb (diff) | |
download | luacov-7d2c47839afa38d5c521ca7377723d4fa8ccf9b2.tar.gz |
Print warning when a source file is not found
Also remove redundant try-finally.
Diffstat (limited to 'src')
-rw-r--r-- | src/luacov/reporter.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/luacov/reporter.lua b/src/luacov/reporter.lua index 3d514b7..e1da371 100644 --- a/src/luacov/reporter.lua +++ b/src/luacov/reporter.lua @@ -440,10 +440,12 @@ function ReporterBase:run() for _, filename in ipairs(self:files()) do local file = io.open(filename, "r") - local file_hits, file_miss = 0, 0 - local ok, err - if file then ok, err = pcall(function() -- try + + if not file then + print("Could not open file " .. filename) + else self:on_new_file(filename) + local file_hits, file_miss = 0, 0 local filedata = self:stats(filename) local line_nr = 1 @@ -468,9 +470,8 @@ function ReporterBase:run() line_nr = line_nr + 1 end - end) -- finally + file:close() - assert(ok, err) self:on_end_file(filename, file_hits, file_miss) end end |