Commit 5f3b95e116fe70a8e647b1605dea60a3713910cf
Committed by
Paulo Meireles
1 parent
3cb6f6bb
Exists in
master
and in
29 other branches
[Mezuro] Added new way of handling exceptions: error_page
Showing
5 changed files
with
21 additions
and
20 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
... | ... | @@ -2,11 +2,17 @@ class MezuroPluginMyprofileController < ProfileController |
2 | 2 | |
3 | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../views') |
4 | 4 | |
5 | - | |
5 | + rescue_from Exception do |exception| | |
6 | + message = URI.escape(CGI.escape(exception.message),'.') | |
7 | + redirect_to "/myprofile/#{profile.identifier}/plugin/mezuro/error_page?message=#{message}" | |
8 | + end | |
9 | + | |
10 | + def error_page | |
11 | + end | |
12 | + | |
6 | 13 | def choose_base_tool |
7 | 14 | @configuration_content = profile.articles.find(params[:id]) |
8 | 15 | @base_tools = Kalibro::BaseTool.all_names |
9 | - @base_tools = [] if @base_tools.first.is_a? Exception | |
10 | 16 | end |
11 | 17 | |
12 | 18 | def choose_metric |
... | ... | @@ -15,17 +21,17 @@ class MezuroPluginMyprofileController < ProfileController |
15 | 21 | base_tool = Kalibro::BaseTool.find_by_name(@base_tool) |
16 | 22 | @supported_metrics = base_tool.nil? ? [] : base_tool.supported_metrics |
17 | 23 | end |
18 | - | |
24 | + | |
19 | 25 | def new_metric_configuration |
20 | 26 | @configuration_content = profile.articles.find(params[:id]) |
21 | 27 | @metric = Kalibro::BaseTool.find_by_name(params[:base_tool]).metric params[:metric_name] |
22 | 28 | end |
23 | - | |
29 | + | |
24 | 30 | def new_compound_metric_configuration |
25 | 31 | @configuration_content = profile.articles.find(params[:id]) |
26 | 32 | @metric_configurations = @configuration_content.metric_configurations |
27 | 33 | end |
28 | - | |
34 | + | |
29 | 35 | def edit_metric_configuration |
30 | 36 | @configuration_content = profile.articles.find(params[:id]) |
31 | 37 | @metric_configuration = Kalibro::MetricConfiguration.find_by_configuration_name_and_metric_name(@configuration_content.name, params[:metric_name]) | ... | ... |
plugins/mezuro/lib/kalibro/base_tool.rb
... | ... | @@ -3,19 +3,11 @@ class Kalibro::BaseTool < Kalibro::Model |
3 | 3 | attr_accessor :name, :description, :supported_metric |
4 | 4 | |
5 | 5 | def self.all_names |
6 | - begin | |
7 | - request("BaseTool", :get_base_tool_names)[:base_tool_name].to_a | |
8 | - rescue Exception => exception | |
9 | - [exception] | |
10 | - end | |
6 | + request("BaseTool", :get_base_tool_names)[:base_tool_name].to_a | |
11 | 7 | end |
12 | 8 | |
13 | 9 | def self.find_by_name(base_tool_name) |
14 | - begin | |
15 | - new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] | |
16 | - rescue Exception | |
17 | - nil | |
18 | - end | |
10 | + new request("BaseTool", :get_base_tool, {:base_tool_name => base_tool_name})[:base_tool] | |
19 | 11 | end |
20 | 12 | |
21 | 13 | def supported_metric=(value) | ... | ... |
plugins/mezuro/lib/kalibro/configuration.rb
... | ... | @@ -21,7 +21,7 @@ class Kalibro::Configuration < Kalibro::Model |
21 | 21 | def self.find_by_name(configuration_name) |
22 | 22 | begin |
23 | 23 | new request("Configuration", :get_configuration, {:configuration_name => configuration_name})[:configuration] |
24 | - rescue Exception => error | |
24 | + rescue Exception | |
25 | 25 | nil |
26 | 26 | end |
27 | 27 | end | ... | ... |
plugins/mezuro/lib/kalibro/model.rb
... | ... | @@ -60,11 +60,11 @@ class Kalibro::Model |
60 | 60 | end |
61 | 61 | |
62 | 62 | def destroy |
63 | - # begin | |
63 | + begin | |
64 | 64 | self.class.request(destroy_endpoint, destroy_action, destroy_params) |
65 | - #rescue Exception => exception | |
66 | - # add_error exception | |
67 | - #end | |
65 | + rescue Exception => exception | |
66 | + add_error exception | |
67 | + end | |
68 | 68 | end |
69 | 69 | |
70 | 70 | protected | ... | ... |
plugins/mezuro/views/mezuro_plugin_myprofile/error_page.html.erb
0 → 100644