mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-05 22:31:11 +08:00
Change where exceptions are caught
This commit is contained in:
parent
96d11f8d0e
commit
c4a726fd08
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user