ref: refs/heads/master
commit df1fcffd864cc1e9145d0fce04682b600fb399bb
Author: Klaus Kämpf
Date: Mon Jul 13 16:27:11 2009 +0200
Don't put exceptions into flash[]
---
.../app/controllers/controlpanel_controller.rb | 3 ++-
webclient/app/controllers/sessions_controller.rb | 13 +++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/webclient/app/controllers/controlpanel_controller.rb b/webclient/app/controllers/controlpanel_controller.rb
index 336867c..16ab0c3 100644
--- a/webclient/app/controllers/controlpanel_controller.rb
+++ b/webclient/app/controllers/controlpanel_controller.rb
@@ -49,7 +49,8 @@ class ControlpanelController < ApplicationController
flash[:error] = YaST::ServiceResource.error(e)
return
rescue Exception => e
- flash[:error] = e
+ flash[:error] = "An exception was raised. Check the logs."
+ logger.error e
return
end
diff --git a/webclient/app/controllers/sessions_controller.rb b/webclient/app/controllers/sessions_controller.rb
index 8629ac3..d703888 100644
--- a/webclient/app/controllers/sessions_controller.rb
+++ b/webclient/app/controllers/sessions_controller.rb
@@ -48,8 +48,9 @@ class SessionsController < ApplicationController
# if the create action is called without the hostname
# it will show the login form
def create
+ hostname = params[:hostname]
# if the user or password is not there, then render the login form
- if params[:hostname].blank?
+ if hostname.blank?
flash[:warning] = _("You need to specify the hostname")
redirect_to :action => "new"
elsif params[:login].blank?
@@ -57,24 +58,24 @@ class SessionsController < ApplicationController
redirect_to :action => "new", :hostname => params[:hostname]
elsif params[:password].blank?
flash[:warning] = _("No password specified")
- redirect_to :action => "new", :login => params[:login], :hostname => params[:hostname]
+ redirect_to :action => "new", :login => params[:login], :hostname => hostname
else
# otherwise, we have all the data, try to login
begin
self.current_account, auth_token = Account.authenticate(params[:login],
params[:password],
- params[:hostname])
+ hostname)
# error handling when login to the service is pretty
# important to get meaningful error messages to the user
rescue Errno::ECONNREFUSED => e
- flash[:error] = _("Can't connect to host at #{params[:hostname]}, make sure the host is up and that the YaST web service is running.")
+ flash[:error] = _("Can't connect to host at #{hostname}, make sure the host is up and that the YaST web service is running.")
redirect_to :action => "new"
return
rescue Exception => e
logger.warn e.to_s
logger.info e.backtrace.join("\n")
- flash[:error] = _("Error when trying to login: #{e.to_s}")
- redirect_to :action => "new", :hostname => params[:hostname]
+ flash[:error] = _("Exception raised when trying to login to #{hostname}. Please try again")
+ redirect_to :action => "new", :hostname => hostname
return
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org