Commit cea68abda65ec572d1e25ab9c6314b5808157bc1
Committed by
João M. M. da Silva
1 parent
c5935295
Exists in
master
and in
29 other branches
[Mezuro] handle exceptions in base_tool
Showing
2 changed files
with
13 additions
and
3 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... | ... | @@ -6,12 +6,14 @@ class MezuroPluginMyprofileController < ProfileController |
6 | 6 | def choose_base_tool |
7 | 7 | @configuration_content = profile.articles.find(params[:id]) |
8 | 8 | @base_tools = Kalibro::BaseTool.all_names |
9 | + @base_tools = [] if @base_tools.first.is_a? Exception | |
9 | 10 | end |
10 | 11 | |
11 | 12 | def choose_metric |
12 | 13 | @configuration_content = profile.articles.find(params[:id]) |
13 | 14 | @base_tool = params[:base_tool] |
14 | - @supported_metrics = Kalibro::BaseTool.find_by_name(@base_tool).supported_metrics | |
15 | + base_tool = Kalibro::BaseTool.find_by_name(@base_tool) | |
16 | + @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics | |
15 | 17 | end |
16 | 18 | |
17 | 19 | def new_metric_configuration | ... | ... |
plugins/mezuro/lib/kalibro/base_tool.rb
... | ... | @@ -3,11 +3,19 @@ class Kalibro::BaseTool < Kalibro::Model |
3 | 3 | attr_accessor :name, :description, :supported_metric |
4 | 4 | |
5 | 5 | def self.all_names |
6 | - request("BaseTool", :get_base_tool_names)[:base_tool_name].to_a | |
6 | + begin | |
7 | + request("BaseTool", :get_base_tool_names)[:base_tool_name].to_a | |
8 | + rescue Exception => exception | |
9 | + [exception] | |
10 | + end | |
7 | 11 | end |
8 | 12 | |
9 | 13 | def self.find_by_name(base_tool_name) |
10 | - new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] | |
14 | + begin | |
15 | + new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] | |
16 | + rescue Exception | |
17 | + nil | |
18 | + end | |
11 | 19 | end |
12 | 20 | |
13 | 21 | def supported_metric=(value) | ... | ... |