Mailinglist Archive: yast-devel (126 mails)

< Previous Next >
[yast-devel] Re: [yast-commit] <web-client> master : showing flash if no data is available (bnc#524614)
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Thu, 12 Nov 2009 15:17:05 +0100
  • Message-id: <200911121517.05459.jreidinger@xxxxxxx>
Stefan Schubert write:
ref: refs/heads/master
commit a31f5e4c62058ff85094a86c38ff574bb3e067db
Author: Stefan Schubert <schubi@xxxxxxx>
Date: Thu Nov 12 10:12:42 2009 +0100

showing flash if no data is available (bnc#524614)
---
.../status/app/controllers/status_controller.rb | 25
+++++++++++++++++-- 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/plugins/status/app/controllers/status_controller.rb
b/plugins/status/app/controllers/status_controller.rb index
012449f..7b4cf03 100644
--- a/plugins/status/app/controllers/status_controller.rb
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -101,11 +101,30 @@ class StatusController < ApplicationController

till = Time.new
from = till - 300 #last 5 minutes
- ActionController::Base.benchmark("Status data read from the server")
do - status = @client.find(:dummy_param, :params => { :start =>
from.to_i.to_s, :stop => till.to_i.to_s }) + begin
+ ActionController::Base.benchmark("Status data read from the server")
do + status = @client.find(:dummy_param, :params => { :start =>
from.to_i.to_s, :stop => till.to_i.to_s }) + end
+ create_data_map status
+ rescue Exception => e

^^^
catch general Exception is not good idea, as it can enclose bugs.
If you have for missing data proper BackendException with its unique
identifier and you can check there simple as

rescue Exception => e
raise e unless ClientException.new(e).backend_exception_type ==
"YOUR_ID"
flash...etc...
end

This catch only expected exception and other is not hidden and properly
reported ( e.g. this change breaks control center, as on my pc AJAX set this
message stuff which is then showed in language module which I select.)

Josef

+ flash[:warning] = e.message
+ logger.warn e
end
- create_data_map status
# logger.debug @data_group.inspect
+
+ #checking if there is one valid data entry at least
+ found = false
+ @data_group.each do |key, map|
+ map.each do |graph_key, list_value|
+ unless list_value.empty?
+ found = true
+ break
+ end
+ end
+ break if found
+ end
+ flash[:notice] = _("No data found for showing system status.") unless
found +
true
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 >
This Thread
  • No further messages