mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-06-24 18:11:12 +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]
|
labels = series[x_col]
|
||||||
values = series[y_col].map(&:to_f)
|
values = series[y_col].map(&:to_f)
|
||||||
end
|
end
|
||||||
begin
|
|
||||||
UnicodePlot.barplot(labels, values, **params.to_hc)
|
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def histogram(data, params)
|
def histogram(data, params)
|
||||||
|
@ -65,7 +65,17 @@ module YouPlot
|
|||||||
|
|
||||||
pp @data if options[:debug]
|
pp @data if options[:debug]
|
||||||
|
|
||||||
|
if YouPlot.run_as_executable?
|
||||||
|
begin
|
||||||
plot = create_plot
|
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)
|
output_plot(plot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,13 +164,13 @@ module YouPlot
|
|||||||
|
|
||||||
def sub_parser_add_xlim
|
def sub_parser_add_xlim
|
||||||
sub_parser.on_head('--xlim FLOAT,FLOAT', Array, 'plotting range for the x coordinate') do |v|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def sub_parser_add_ylim
|
def sub_parser_add_ylim
|
||||||
sub_parser.on_head('--ylim FLOAT,FLOAT', Array, 'plotting range for the y coordinate') do |v|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user