Change where exceptions are caught

This commit is contained in:
kojix2 2021-01-22 11:07:33 +09:00
parent 96d11f8d0e
commit c4a726fd08
3 changed files with 14 additions and 16 deletions

View File

@ -39,19 +39,7 @@ module YouPlot
labels = series[x_col]
values = series[y_col].map(&:to_f)
end
begin
UnicodePlot.barplot(labels, values, **params.to_hc)
# UnicodePlot error:
# All values have to be positive. Negative bars are not supported.
rescue ArgumentError => e
if YouPlot.run_as_executable?
warn e.backtrace[0]
warn "\e[35m#{e}\e[0m"
exit 1
else
raise e
end
end
UnicodePlot.barplot(labels, values, **params.to_hc)
end
def histogram(data, params)

View File

@ -65,7 +65,17 @@ module YouPlot
pp @data if options[:debug]
plot = create_plot
if YouPlot.run_as_executable?
begin
plot = create_plot
rescue ArgumentError => e
warn e.backtrace[0]
warn "\e[35m#{e}\e[0m"
exit 1
end
else
plot = create_plot
end
output_plot(plot)
end

View File

@ -164,13 +164,13 @@ module YouPlot
def sub_parser_add_xlim
sub_parser.on_head('--xlim FLOAT,FLOAT', Array, 'plotting range for the x coordinate') do |v|
params.xlim = v.take(2)
params.xlim = v
end
end
def sub_parser_add_ylim
sub_parser.on_head('--ylim FLOAT,FLOAT', Array, 'plotting range for the y coordinate') do |v|
params.ylim = v.take(2)
params.ylim = v
end
end