ref: refs/heads/master
commit cb9de3564b8a54eb0d4bb3a2f07eece139c805ac
Author: Stefan Schubert
Date: Mon Nov 2 16:54:35 2009 +0100
robuster client_exception. Showing an exception if it really exists (bnc #550717)
---
.../app/controllers/patch_updates_controller.rb | 4 ++--
webclient/lib/client_exception.rb | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/plugins/patch_updates/app/controllers/patch_updates_controller.rb b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
index beb3da7..a8614a0 100644
--- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
+++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
@@ -24,7 +24,7 @@ class PatchUpdatesController < ApplicationController
begin
patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all
rescue Exception => e
- error = e
+ error = ClientException.new(e)
patch_updates = nil
end
@@ -43,7 +43,7 @@ class PatchUpdatesController < ApplicationController
end
respond_to do |format|
- format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary, :error => ClientException.new(error) } }
+ format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary, :error => error } }
format.json { render :json => patches_summary }
end
end
diff --git a/webclient/lib/client_exception.rb b/webclient/lib/client_exception.rb
index 405864c..6546940 100644
--- a/webclient/lib/client_exception.rb
+++ b/webclient/lib/client_exception.rb
@@ -43,31 +43,32 @@ class ClientException < Exception
# happened there, or the local one if it is a normal exception
def message
return @err_msg unless @err_msg.blank?
- return @excpt.message
+ return @excpt.message if @excpt
end
# remote exception type as a string or "UNDEFINED"
def backend_exception_type
- return @error_data['type'] if @error_data.has_key?('type')
+ return @error_data['type'] if (@error_data && @error_data.has_key?('type'))
"UNDEFINED"
end
# if the exception was produced because another exception
# happened at the server side
def backend_exception?
- @excpt.is_a?(ActiveResource::ServerError) and
+ @excpt and @excpt.is_a?(ActiveResource::ServerError) and
@excpt.response.code.to_s =~ /.*503.*|.*500.*/
end
# if the exception is discarded to be a bug, like
# a service not running on the server side
def bug?
- return @error_data['bug'] if @error_data.has_key?('bug')
+ return @error_data['bug'] if (@error_data && @error_data.has_key?('bug'))
true
end
def backtrace
- @excpt.backtrace
+ return @excpt.backtrace if (@excpt && !@excpt.backtrace.blank?)
+ []
end
# forward any other method
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org