Mailinglist Archive: yast-devel (126 mails)

< Previous Next >
Re: [yast-devel] Re: [yast-commit] <web-client> master : cleanup exception handling espl. not running collectd (bnc#555205)
  • From: Stefan Schubert <schubi@xxxxxxxxxx>
  • Date: Thu, 19 Nov 2009 14:57:04 +0100
  • Message-id: <4B054EB0.2020708@xxxxxxxxxx>
Josef Reidinger schrieb:
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"]

I think that this is the "second" best way :-) The best way would be to tell the service which language currently is selected in the UI.
So, the service can return messages in the correct language.
Especially for cases like user module where error messages comes from the yast2-user module.
Another example would be SuSERegister which has also the possibility to return messages
in the selected translation.

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



--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
References