aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb18
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb16
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb8
7 files changed, 36 insertions, 23 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb
index bc7e9ec7cd5..3f3f1a1f746 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/api_controller.rb
@@ -79,7 +79,7 @@ class Api::ApiController < ApplicationController
#
def render_error(exception, status=500)
- message = exception.respond_to?('message') ? Api::Utils.exception_message(exception) : exception.to_s
+ message = exception.respond_to?('message') ? Api::Utils.exception_message(exception, :backtrace => true) : exception.to_s
java_facade.logError("Fail to render: #{request.url}\n#{message}") if status==500
respond_to do |format|
format.json { render :json => error_to_json(status, message), :status => status }
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
index 3b382a1b324..8636de40e54 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
@@ -145,7 +145,7 @@ class ApplicationController < ActionController::Base
def render_error(error)
# Ruby on Rails has a single logger "rails", so it's not possible to distinguish profiling logs
# from error logs. For this reason a standard SLF4J logger is used instead of logger.error().
- java_facade.logError("Fail to render: #{request.url}\n#{Api::Utils.exception_message(error)}")
+ java_facade.logError("Fail to render: #{request.url}\n#{Api::Utils.exception_message(error, :backtrace => true)}")
if request.xhr?
message = error.respond_to?('message') ? error.message : error.to_s
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb
index b53541094a6..68d1818e4e5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb
@@ -266,10 +266,15 @@ class ProjectReviewsController < ApplicationController
access_denied unless has_rights_to_modify?(@review.resource)
bad_request('Missing command') if params[:command].blank?
- RuleFailure.execute_command(params[:command], @review.violation, @review.resource.project, current_user, params)
+ error_message = nil
+ begin
+ RuleFailure.execute_command(params[:command], @review.violation, @review.resource.project, current_user, params)
+ rescue Exception => e
+ error_message=Api::Utils.exception_message(e, :backtrace => false)
+ end
@review.reload
- render :partial => "project_reviews/view"
+ render :partial => "project_reviews/view", :locals => {:review => @review, :error_message => error_message}
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
index cfc7eccb2a6..d30e078e7e9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
@@ -68,14 +68,19 @@ class ReviewsController < ApplicationController
violation.create_review!(:user_id => current_user.id)
end
- # TODO remove parameters id and command from params
- RuleFailure.execute_command(params[:command], violation, violation.snapshot.root_snapshot.project, current_user, params)
+ # TODO remove parameters 'id' and 'command' from params
+ error_message = nil
+ begin
+ RuleFailure.execute_command(params[:command], violation, violation.snapshot.root_snapshot.project, current_user, params)
+ rescue Exception => e
+ error_message=Api::Utils.exception_message(e, :backtrace => false)
+ end
# reload data required for display
violation.reload
screens = violation.available_java_screens(current_user)
- render :partial => 'resource/violation', :locals => {:violation => violation, :review_screens => screens}
+ render :partial => 'resource/violation', :locals => {:violation => violation, :review_screens => screens, :error_message => error_message}
end
#
@@ -200,12 +205,7 @@ class ReviewsController < ApplicationController
if params[:comment_id]
violation.review.edit_comment(current_user, params[:comment_id].to_i, params[:text])
else
- begin
- violation.review.create_comment({:user => current_user, :text => params[:text]}, params[:review_command_id])
- rescue Exception => e
- # the review command may throw an exception
- flash["review_error_#{violation.id}"] = e.clean_message
- end
+ violation.review.create_comment({:user => current_user, :text => params[:text]}, params[:review_command_id])
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
index 7ceec9ad93b..fd7bc1d432d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb
@@ -70,10 +70,18 @@ class Api::Utils
Java::OrgSonarServerUi::JRubyFacade.getInstance().getMessage(I18n.locale, key, default, params.to_java)
end
- def self.exception_message(exception)
- result = (exception.respond_to?(:message) ? "#{exception.message}\n" : "#{exception}\n")
- if exception.respond_to? :backtrace
- result << "\t" + exception.backtrace.join("\n\t") + "\n"
+ #
+ # Options :
+ # - backtrace: append backtrace if true. Default value is false.
+ #
+ def self.exception_message(exception, options={})
+ cause = exception
+ if exception.is_a?(NativeException) && exception.respond_to?(:cause)
+ cause = exception.cause
+ end
+ result = (cause.respond_to?(:message) ? "#{cause.message}\n" : "#{cause}\n")
+ if options[:backtrace]==true && cause.respond_to?(:backtrace)
+ result << "\t" + cause.backtrace.join("\n\t") + "\n"
end
result
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb
index 2a159fb6ec7..0dd5a5aa481 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project_reviews/_review.html.erb
@@ -3,8 +3,8 @@
<h2><%= message('reviews.review_number', :params => h(review.id.to_s)) -%> - <%= h(review.title) -%></h2>
</div>
- <% if flash[:review_error] %>
- <div id="review_error" class="error"><%= flash[:review_error] %> <a href="#" onclick="$('review_error').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div>
+ <% if defined?(error_message) && error_message %>
+ <div id="review_error" class="error"><%= h error_message -%> <a href="#" onclick="$('review_error').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div>
<% end %>
<%
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
index 3ae0d57e824..514ab668cb7 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
@@ -106,12 +106,12 @@
end
%>
- <% if flash["review_error_#{violation.id}"] %>
- <div id="review_error_<%= violation.id -%>" class="error"><%= flash["review_error_#{violation.id}"] %> <a href="#" onclick="$('review_error_<%= violation.id -%>').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div>
- <% end %>
-
<% if current_user %>
<div class="vActions" id="vActions<%= violation.id -%>">
+ <% if defined?(error_message) && error_message %>
+ <div id="review_error_<%= violation.id -%>" class="error"><%= h error_message -%> <a href="#" onclick="$('review_error_<%= violation.id -%>').hide(); return false;"><%= message('reviews.hide_this_message') -%></a></div>
+ <% end %>
+
<%= link_to_function message('reviews.comment'), "sCF(#{violation.id})", :name => 'bComment', :class => 'link-action spacer-right' -%>
<% unless violation.review && violation.review.resolved? %>