Mailinglist Archive: yast-devel (233 mails)

< Previous Next >
[yast-devel] Re: [yast-commit] <web-client> master : catch administrator module error
  • From: josef reidinger <jreidinger@xxxxxxx>
  • Date: Fri, 02 Oct 2009 12:34:53 +0200
  • Message-id: <4AC5D74D.7040506@xxxxxxx>
Jiri Suchomel napsal(a):
ref: refs/heads/master
commit fbd826698582334e4b1e360ba91f09e50f54e933
Author: Jiri Suchomel <jsuchome@xxxxxxx>
Date: Fri Oct 2 11:47:49 2009 +0200

catch administrator module error
---
.../app/controllers/administrator_controller.rb | 6 ++++++
.../views/shared/backendexception_trap.html.erb | 2 +-
webclient/lib/error_constructor.rb | 5 ++++-
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git
a/plugins/administrator/app/controllers/administrator_controller.rb
b/plugins/administrator/app/controllers/administrator_controller.rb
index 6d63764..39b7720 100644
--- a/plugins/administrator/app/controllers/administrator_controller.rb
+++ b/plugins/administrator/app/controllers/administrator_controller.rb
@@ -61,6 +61,12 @@ class AdministratorController < ApplicationController
response = @administrator.save
rescue ActiveResource::ClientError => e
flash[:error] = YaST::ServiceResource.error(e)
+ logger.warn e.inspect
+ # handle backend exception here, not by generic handler:
+ rescue ActiveResource::ServerError => e
+ error = Hash.from_xml e.response.body
+ logger.warn error.inspect
+ flash[:error] = _("Error while savig administrator settings:
#{error["error"]["output"]}")

Hi, this has same problem as I say yesterday to mzugec. This is good but
you don't expect any other exception which could backend raise like
permission problems.
So I suggest same as in network
if error["error"] && error["error"]["type"] == ADMINISTRATOR_ERROR
flash[:error] = _("Error while savig administrator settings:
#{error["error"]["output"]}")
else
raise e #don't handle exception which is not related to setting
administrator
end

JFYI typo in saving

end

if params.has_key? "commit"
diff --git a/webclient/app/views/shared/backendexception_trap.html.erb
b/webclient/app/views/shared/backendexception_trap.html.erb
index 1fa97b6..6e643bf 100644
--- a/webclient/app/views/shared/backendexception_trap.html.erb
+++ b/webclient/app/views/shared/backendexception_trap.html.erb
@@ -1,7 +1,7 @@

<h1><%= _("This is embarrasing....") %></h1>

-<p><%= _("Problem occur on target machine.") %></p>
+<p><%= _("Problem occured on target machine.") %></p>

<h3><%= _("Problem:") %></h3>

diff --git a/webclient/lib/error_constructor.rb
b/webclient/lib/error_constructor.rb
index 0876f58..5504b70 100644
--- a/webclient/lib/error_constructor.rb
+++ b/webclient/lib/error_constructor.rb
@@ -19,7 +19,10 @@ module ErrorConstructor
if error["output"]=="NOSERVERS" #special value indicates that there is
no predefined ntp server
problem = _("There is no predefined ntp server at
/etc/sysconfig/network/config - NETCONFIG_NTP_STATIC_SERVERS")
end
- return _("Error occure during ntp synchronization: #{problem}")
+ return _("Error occured during ntp synchronization: #{problem}")
+ when "ADMINISTRATOR_ERROR"
+ problem = error["output"]
+ return _("Error while savig administrator settings: #{problem}")
else
RAILS_DEFAULT_LOGGER.warn "Untranslated message for exception
#{error["type"]}"
return error["description"]

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

< Previous Next >
This Thread
  • No further messages