Skip to content

Commit 41c0d37

Browse files
committed
Friendly error messages
1 parent a1dcc53 commit 41c0d37

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

lib/youplot/command.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ def run
6363
# normal mode
6464
else
6565
# Sometimes the input file does not end with a newline code.
66-
while (input = Kernel.gets(nil))
66+
begin
67+
begin
68+
input = Kernel.gets(nil)
69+
rescue Errno::ENOENT => e
70+
warn e.message
71+
next
72+
end
6773
main(input)
68-
end
74+
end until input
6975
end
7076
end
7177

@@ -137,6 +143,10 @@ def parse_dsv(input)
137143
warn 'Please try to set the correct character encoding with --encoding option.'
138144
warn e.backtrace.grep(/youplot/).first
139145
exit 1
146+
rescue ArgumentError => e
147+
warn 'Failed to parse the text. '
148+
warn e.backtrace.grep(/youplot/).first
149+
exit 1
140150
end
141151

142152
data

0 commit comments

Comments
 (0)