[yast-commit] <web-client> backgroud_patches_bnc550934 : handle PackageKit errors (bnc #559233)

ref: refs/heads/backgroud_patches_bnc550934 commit 547aa5b85029bdfd4b37ef9464be2494508f4e0d Author: Stefan Schubert <schubi@suse.de> Date: Fri Dec 18 13:51:40 2009 +0100 handle PackageKit errors (bnc #559233) --- .../app/controllers/patch_updates_controller.rb | 32 ++++++++++++++++--- .../views/patch_updates/_patch_summary.html.erb | 2 +- .../app/views/patch_updates/index.html.erb | 2 +- .../package/yast2-webclient-patch_updates.changes | 5 +++ 4 files changed, 34 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 79d5f73..db14fb3 100644 --- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb +++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb @@ -13,7 +13,19 @@ class PatchUpdatesController < ApplicationController # GET /patch_updates # GET /patch_updates.xml def index - @patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all + begin + @patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all + rescue ActiveResource::ServerError => e + error_hash = Hash.from_xml e.response.body + logger.warn error_hash.inspect + if error_hash["error"] && error_hash["error"]["type"] == "PACKAGEKIT_ERROR" + flash[:error] = error_hash["error"]["description"] + @patch_updates = [] + @error = true + else + raise e + end + end logger.debug "Available patches: #{@patch_updates.inspect}" end @@ -23,11 +35,21 @@ class PatchUpdatesController < ApplicationController patch_updates = nil begin patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all - rescue Exception => e + rescue ActiveResource::ClientError => e error = ClientException.new(e) patch_updates = nil - end - + error_string = _("A problem occured when loading patch information.") + rescue ActiveResource::ServerError => e + error_hash = Hash.from_xml e.response.body + logger.warn error_hash.inspect + if error_hash["error"] && error_hash["error"]["type"] == "PACKAGEKIT_ERROR" + error_string = error_hash["error"]["description"] + else + error_string = _("A problem occured when loading patch information.") + end + error = ClientException.new(e) + patch_updates = nil + end patches_summary = nil if patch_updates @@ -43,7 +65,7 @@ class PatchUpdatesController < ApplicationController end respond_to do |format| - format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary, :error => error } } + format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary, :error => error, :error_string => error_string } } format.json { render :json => patches_summary } end end diff --git a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb index 37e9aac..1a15282 100644 --- a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb +++ b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb @@ -1,4 +1,4 @@ -<%= report_error(error, _("A problem occured when loading patch information.")) if error %> +<%= report_error(error, error_string) if error %> <div class="status_patches"> <% unless patch %> diff --git a/plugins/patch_updates/app/views/patch_updates/index.html.erb b/plugins/patch_updates/app/views/patch_updates/index.html.erb index 6892ff2..26c7b67 100644 --- a/plugins/patch_updates/app/views/patch_updates/index.html.erb +++ b/plugins/patch_updates/app/views/patch_updates/index.html.erb @@ -12,7 +12,7 @@ <div class='plugin-content grid_12'> <div class="loading"></div> <% if @patch_updates.empty? %> - <h3><%=_("Your system is up to date.") %></h3> + <h3><%=_("Your system is up to date.") unless @error%></h3> <%= link_to _("Back"), '/', :class=>"button" %> <% else %> <h3><%=_("Updates available") %></h3> diff --git a/plugins/patch_updates/package/yast2-webclient-patch_updates.changes b/plugins/patch_updates/package/yast2-webclient-patch_updates.changes index 88f4032..a7d1bdf 100644 --- a/plugins/patch_updates/package/yast2-webclient-patch_updates.changes +++ b/plugins/patch_updates/package/yast2-webclient-patch_updates.changes @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Thu Dec 17 14:15:52 CET 2009 - schubi@suse.de + +- handle PackageKit errors (bnc #559233) + +------------------------------------------------------------------- Thu Nov 5 13:30:04 CET 2009 - schubi@suse.de - update translation -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
Stefan Schubert