incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 4/4] RHEV-M driver updated to support new error handling
Date Wed, 27 Apr 2011 11:08:00 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/lib/deltacloud/base_driver/exceptions.rb    |    3 ++
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   23 ++++++++++++-------
 server/tests/drivers/mock/api_test.rb              |    4 +-
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/exceptions.rb b/server/lib/deltacloud/base_driver/exceptions.rb
index e7b6ac8..38f18d2 100644
--- a/server/lib/deltacloud/base_driver/exceptions.rb
+++ b/server/lib/deltacloud/base_driver/exceptions.rb
@@ -28,6 +28,9 @@ module Deltacloud
     end
 
     class BackendError < DeltacloudException
+
+      attr_accessor :cause
+
       def initialize(e, details)
         super(500, e.class.name, e.message, e.backtrace, details)
       end
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index fbaaf64..7aa6a2a 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -277,15 +277,20 @@ class RHEVMDriver < Deltacloud::BaseDriver
     )
   end
 
-  # Disabling this error catching will lead to more verbose messages
-  # on console (eg. response from RHEV-M API (so far I didn't figure our
-  # how to pass those message to our exception handling tool)
-  def catched_exceptions_list
-    {
-      :auth => [RestClient::Unauthorized],
-      :error => [RestClient::InternalServerError],
-      :glob => [ /(RestClient|RHEVM)::(\w+)/ ]
-    }
+  exceptions do
+
+    on /RestClient::Unauthorized/ do
+      status 401
+    end
+
+    on /RestClient::InternalServerError/ do
+      status 502
+    end
+
+    on /(RestClient|RHEVM)/ do
+      status 500
+    end
+
   end
 
 end
diff --git a/server/tests/drivers/mock/api_test.rb b/server/tests/drivers/mock/api_test.rb
index 0d86ef5..5767103 100644
--- a/server/tests/drivers/mock/api_test.rb
+++ b/server/tests/drivers/mock/api_test.rb
@@ -69,7 +69,7 @@ module DeltacloudUnitTest
 
       with_provider("storage") do
         get_auth_url '/api/instances'
-        last_response.status.should == 404
+        last_response.status.should == 403
       end
     end
 
@@ -79,7 +79,7 @@ module DeltacloudUnitTest
 
       with_provider("storage") do
         get_url '/api/docs/instances'
-        last_response.status.should == 404
+        last_response.status.should == 403
       end
     end
 
-- 
1.7.4.1


Mime
View raw message