Commit 3cb6f6bb46edba67c0178653e17c488d78e096cc

Authored by João M. M. da Silva + Alessandro Palmeira
Committed by Paulo Meireles
1 parent d23a42e4

[Mezuro] handle exceptions in base_tool

plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
@@ -6,12 +6,14 @@ class MezuroPluginMyprofileController < ProfileController @@ -6,12 +6,14 @@ class MezuroPluginMyprofileController < ProfileController
6 def choose_base_tool 6 def choose_base_tool
7 @configuration_content = profile.articles.find(params[:id]) 7 @configuration_content = profile.articles.find(params[:id])
8 @base_tools = Kalibro::BaseTool.all_names 8 @base_tools = Kalibro::BaseTool.all_names
  9 + @base_tools = [] if @base_tools.first.is_a? Exception
9 end 10 end
10 11
11 def choose_metric 12 def choose_metric
12 @configuration_content = profile.articles.find(params[:id]) 13 @configuration_content = profile.articles.find(params[:id])
13 @base_tool = params[:base_tool] 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 end 17 end
16 18
17 def new_metric_configuration 19 def new_metric_configuration
plugins/mezuro/lib/kalibro/base_tool.rb
@@ -3,11 +3,19 @@ class Kalibro::BaseTool < Kalibro::Model @@ -3,11 +3,19 @@ class Kalibro::BaseTool < Kalibro::Model
3 attr_accessor :name, :description, :supported_metric 3 attr_accessor :name, :description, :supported_metric
4 4
5 def self.all_names 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 end 11 end
8 12
9 def self.find_by_name(base_tool_name) 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 end 19 end
12 20
13 def supported_metric=(value) 21 def supported_metric=(value)