diff options
author | Leah Neukirchen <leah@vuxu.org> | 2017-10-29 21:45:42 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2017-10-29 21:45:42 +0100 |
commit | 1610bec4dfc70709e614f824e867e4b8baaafb87 (patch) | |
tree | a9fbb86c02232fffe23a9a9523e239c615468b73 | |
parent | 31c4e03534c24062101aaebf659e0a634e221a1b (diff) | |
download | notyet-1610bec4dfc70709e614f824e867e4b8baaafb87.tar.gz notyet-1610bec4dfc70709e614f824e867e4b8baaafb87.tar.xz notyet-1610bec4dfc70709e614f824e867e4b8baaafb87.zip |
error handling for #include foo
-rwxr-xr-x | notyet | 15 |
1 files 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| |