Mailinglist Archive: yast-devel (126 mails)

< Previous Next >
[yast-devel] Re: [yast-commit] <web-client> master : cleanup exception handling espl. not running collectd (bnc#555205)
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Thu, 19 Nov 2009 13:00:11 +0100
  • Message-id: <200911191300.11941.jreidinger@xxxxxxx>
Stefan Schubert write:
ref: refs/heads/master
commit 4ab44123fb323d1dd41e6616a80c1baeeae3d4ca
Author: Stefan Schubert <schubi@xxxxxxx>
Date: Thu Nov 19 11:08:47 2009 +0100

cleanup exception handling espl. not running collectd (bnc#555205)
---
.../status/app/controllers/status_controller.rb | 40
++++++++++++++----- 1 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/plugins/status/app/controllers/status_controller.rb
b/plugins/status/app/controllers/status_controller.rb index
4936a53..ca521b8 100644
--- a/plugins/status/app/controllers/status_controller.rb
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -154,15 +154,24 @@ class StatusController < ApplicationController

def index
return unless client_permissions
-
- log = YaST::ServiceResource.proxy_for('org.opensuse.yast.system.logs')
- @logs = log.find(:all)
- flash[:notice] = _("No data found for showing system status.") unless
create_data - limits_reached
- logger.debug "limits reached for #{@limits_list[:reached].inspect}"
+ begin
+ log =
YaST::ServiceResource.proxy_for('org.opensuse.yast.system.logs') +
@logs = log.find(:all)
+ flash[:notice] = _("No data found for showing system status.")
unless create_data + limits_reached
+ logger.debug "limits reached for #{@limits_list[:reached].inspect}"
+ rescue ActiveResource::ServerError => error
+ error_hash = Hash.from_xml error.response.body
+ logger.warn error_hash.inspect
+ if error_hash["error"] &&
+ (error_hash["error"]["type"] == "SERVICE_NOT_RUNNING" ||
error_hash["error"]["type"] == "NO_PERM") + flash[:error] =
error_hash["error"]["description"]

Hi, few notes.
You can benefit here from clientException class, so you can use
exception = ClinetException.new(error)
if ["SERVICE_NOT_RUNNING","NO_PERM"].include? exception.backend_exception_type
flash[:error] = exception.message #bonus you have localized message from
ErrorConstructor class (just add localization string here)
else
...
end

+ else
+ raise error
+ end
+ end
end

-
def show_summary
return unless client_permissions
begin
@@ -173,10 +182,19 @@ class StatusController < ApplicationController
status = _("No data found for showing system status.")
end
render :partial => "status_summary", :locals => { :status => status,
:error => nil } - rescue Exception => error
- erase_redirect_results #reset all redirects
- erase_render_results
- render :partial => "status_summary", :locals => { :status => nil,
:error => ClientException.new(error) } and return + rescue
ActiveResource::ClientError => error
+ logger.warn error.inspect
+ render :partial => "status_summary", :locals => { :status => nil,
:error => ClientException.new(error) } and return + rescue
ActiveResource::ServerError => error
+ error_hash = Hash.from_xml error.response.body
+ logger.warn error_hash.inspect
+ if error_hash["error"] &&
+ (error_hash["error"]["type"] == "SERVICE_NOT_RUNNING" ||
error_hash["error"]["type"] == "NO_PERM") + status =
error_hash["error"]["description"]
same as above.

Josef
+ render :partial => "status_summary", :locals => { :status =>
status, :error => nil } + else
+ render :partial => "status_summary", :locals => { :status =>
nil, :error => ClientException.new(error) } + end
end
end


--
Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast
(language,time,basesystem,ntp)
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups