From 1610bec4dfc70709e614f824e867e4b8baaafb87 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sun, 29 Oct 2017 21:45:42 +0100 Subject: error handling for #include --- notyet | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/notyet b/notyet index 712ccc2..2745656 100755 --- a/notyet +++ b/notyet @@ -153,11 +153,16 @@ def parse(io, filename=nil) } next if children.empty? elsif desc =~ /^#include\s+(\S+)/ - File.open(File.expand_path($1, File.dirname(fname))) { |f| - sub = parse(f, $1) - sub.reindent(i+2) - children = sub.children - } + n = File.expand_path($1, File.dirname(fname)) + begin + File.open(n) { |f| + sub = parse(f, $1) + sub.reindent(i+2) + children = sub.children + } + rescue SystemCallError => e + children = [Entry.new(i+2, "?", "ERROR: #{e}", fname, lineno, [])] + end next if children.empty? elsif desc =~ /^#includeall\s+(\S+)/ Dir.glob(File.expand_path($1, File.dirname(fname))) { |file| -- cgit 1.4.1