ref: refs/heads/master
commit 993389704da3c72b43754ac3cbc2bd8bbd35dda0
Author: Duncan Mac-Vicar P
Date: Tue Sep 1 16:21:44 2009 +0200
Error handling improved
See http://en.opensuse.org/YaST/Web/Development/Error_Handling
for more information.
New features:
- unhandled ajax errors are displayed in the standard flash messages
facility, using standard jquery.ui styles
- provide helper report_error to put an exception into the flash
message area
- popup to examine backtrace and copy to clipboard facility
---
.../app/controllers/patch_updates_controller.rb | 10 +-
.../views/patch_updates/_patch_summary.html.erb | 9 +-
.../app/controllers/application_controller.rb | 2 +-
webclient/app/helpers/view_helpers/html_helper.rb | 100 ++++++++++++++++++++
webclient/app/views/controlpanel/index.rhtml | 4 +
webclient/app/views/layouts/main.rhtml | 33 +++++--
.../app/views/shared/_exception_trap.html.erb | 34 +-------
webclient/app/views/shared/exception_trap.html.erb | 10 +-
webclient/public/flash/clippy.swf | Bin 0 -> 5380 bytes
webclient/public/stylesheets/style.css | 13 +++
10 files changed, 158 insertions(+), 57 deletions(-)
diff --git a/plugins/patch_updates/app/controllers/patch_updates_controller.rb b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
index 02623fe..ce42430 100644
--- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
+++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
@@ -14,10 +14,12 @@ class PatchUpdatesController < ApplicationController
# this action is rendered as a partial, so it can't throw
def show_summary
+ error = nil
patch_updates = nil
begin
patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all
- rescue
+ rescue Exception => e
+ error = e
patch_updates = nil
end
@@ -36,11 +38,9 @@ class PatchUpdatesController < ApplicationController
end
respond_to do |format|
- format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary } }
+ format.html { render :partial => "patch_summary", :locals => { :patch => patches_summary, :error => error } }
format.json { render :json => patches_summary }
- end
-
-
+ end
end
def load_filtered
diff --git a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
index de7d9fb..88e3bde 100644
--- a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
+++ b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
@@ -1,8 +1,9 @@
-<div class="status_patches">
- <% unless patch %>
- <div class="status-icon warning"></div>
- <%= _("An error occured when loading patch information.") %>
+<%= report_error(error, _("An error occured when loading patch information.")) if error %>
+<div class="status_patches">
+ <% unless patch %>
+ <div class="status-icon warning"></div>
+ <%= _("No information about patches available") %>
<% else %>
<% link_to "patch_updates" do %>
<% if patch[:security]+patch[:important] > 0 %>
diff --git a/webclient/app/controllers/application_controller.rb b/webclient/app/controllers/application_controller.rb
index d66d802..cfe4e97 100644
--- a/webclient/app/controllers/application_controller.rb
+++ b/webclient/app/controllers/application_controller.rb
@@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base
begin
settings_url = YaST::ServiceResource::Session.site.merge("/vendor_settings/bugzilla_url.json")
@bug_url = ActiveSupport::JSON.decode(open(settings_url).read)
- rescue Exception => e
+ rescue Exception => vendor_excp
@bug_url = "https://bugzilla.novell.com/enter_bug.cgi?classification=7340&product=openSUSE+11.2&submit=Use+This+Product&component=WebYaST&format=guided"
# there was a problem or the setting does not exist
# Here we should handle this always as an error
diff --git a/webclient/app/helpers/view_helpers/html_helper.rb b/webclient/app/helpers/view_helpers/html_helper.rb
index 6fbce27..f02a7a7 100644
--- a/webclient/app/helpers/view_helpers/html_helper.rb
+++ b/webclient/app/helpers/view_helpers/html_helper.rb
@@ -91,6 +91,106 @@ module ViewHelpers::HtmlHelper
return ret
end
+ # clipboard icon for a predefined text
+ def clippy(text, bgcolor='#FFFFFF')
+ html = <<-EOF
+