From 41c0d37a1346556a8bd9b28a17602546180a25b4 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Wed, 25 May 2022 16:24:13 +0900 Subject: [PATCH] Friendly error messages --- lib/youplot/command.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/youplot/command.rb b/lib/youplot/command.rb index 9141ab2..f06899f 100644 --- a/lib/youplot/command.rb +++ b/lib/youplot/command.rb @@ -63,9 +63,15 @@ module YouPlot # normal mode else # Sometimes the input file does not end with a newline code. - while (input = Kernel.gets(nil)) + begin + begin + input = Kernel.gets(nil) + rescue Errno::ENOENT => e + warn e.message + next + end main(input) - end + end until input end end @@ -137,6 +143,10 @@ module YouPlot warn 'Please try to set the correct character encoding with --encoding option.' warn e.backtrace.grep(/youplot/).first exit 1 + rescue ArgumentError => e + warn 'Failed to parse the text. ' + warn e.backtrace.grep(/youplot/).first + exit 1 end data