incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962249 - in /incubator/deltacloud/trunk/server: lib/deltacloud/base_driver/base_driver.rb server.rb views/errors/backend_error.html.haml views/errors/backend_error.xml.haml
Date Thu, 08 Jul 2010 23:40:53 GMT
Author: lutter
Date: Thu Jul  8 23:40:53 2010
New Revision: 962249

URL: http://svn.apache.org/viewvc?rev=962249&view=rev
Log:
Error handling: BackendError for reporting unexplained backend problems

Added:
    incubator/deltacloud/trunk/server/views/errors/backend_error.html.haml
    incubator/deltacloud/trunk/server/views/errors/backend_error.xml.haml
Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
    incubator/deltacloud/trunk/server/server.rb

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb?rev=962249&r1=962248&r2=962249&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/base_driver/base_driver.rb Thu Jul  8
23:40:53 2010
@@ -20,6 +20,16 @@ module Deltacloud
   class AuthException < Exception
   end
 
+  class BackendError < StandardError
+    attr_reader :code, :cause, :details
+    def initialize(code, cause, message, details)
+      super(message)
+      @code = code
+      @cause = cause
+      @details = details
+    end
+  end
+
   class BaseDriver
 
     def self.define_hardware_profile(name,&block)

Modified: incubator/deltacloud/trunk/server/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/server.rb?rev=962249&r1=962248&r2=962249&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/server.rb Thu Jul  8 23:40:53 2010
@@ -81,6 +81,10 @@ error Deltacloud::AuthException do
   report_error(403, "auth_exception")
 end
 
+error Deltacloud::BackendError do
+  report_error(500, "backend_error")
+end
+
 # Redirect to /api
 get '/' do redirect '/api'; end
 

Added: incubator/deltacloud/trunk/server/views/errors/backend_error.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/backend_error.html.haml?rev=962249&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/backend_error.html.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/backend_error.html.haml Thu Jul  8 23:40:53
2010
@@ -0,0 +1,17 @@
+%h1 Backend Error
+
+%p= @error.message
+
+%dl
+  %di
+    %dt Request URL
+    %dd= request.env['REQUEST_URI']
+  %di
+    %dt Code
+    %dd= @error.code
+  %di
+    %dt Cause
+    %dd= @error.cause
+  %di
+    %dt Details
+    %dd= @error.details

Added: incubator/deltacloud/trunk/server/views/errors/backend_error.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/errors/backend_error.xml.haml?rev=962249&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/views/errors/backend_error.xml.haml (added)
+++ incubator/deltacloud/trunk/server/views/errors/backend_error.xml.haml Thu Jul  8 23:40:53
2010
@@ -0,0 +1,8 @@
+%error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
+  %kind backend_error
+  %backend{ :driver => DRIVER }
+    %code= @error.code
+    %cause= @error.cause
+    - if @error.details
+      %details #{@error.details}
+  %message #{@error.message}



Mime
View raw message