diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-23 11:31:14 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-23 11:33:42 +0200 |
commit | 99e41b12a0200c8495de634f9202aea5edfd1ed4 (patch) | |
tree | f499d20ef4333cb1c658bda32cd28f98bf3ec063 /sonar-server/src/main/webapp/WEB-INF/app/models | |
parent | 8a4e4aed35f2b4736eb007f6a168d5baf9db93f0 (diff) | |
download | sonarqube-99e41b12a0200c8495de634f9202aea5edfd1ed4.tar.gz sonarqube-99e41b12a0200c8495de634f9202aea5edfd1ed4.zip |
SONAR-2706 improve error handling on command execution
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/models')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/models/api/utils.rb | 16 |
1 files changed, 12 insertions, 4 deletions
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 |