deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/5] git commit: Core: Throw 501 error when backend does not have capability
Date Wed, 22 Feb 2012 12:33:39 GMT
Updated Branches:
  refs/heads/master fc32d5582 -> 0d3192917


Core: Throw 501 error when backend does not have capability

Previously when backend does not have capability to execute
requested operation we raised a 'Failure' exception which was
then sent to client as 500 (Internal Server Error).
In HTTP 501 is reserved for 'Not Supported' kind of errors.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/0d319291
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/0d319291
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/0d319291

Branch: refs/heads/master
Commit: 0d31929171175de459e2dbde9d13cae611f3efa3
Parents: 401c91a
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Feb 22 13:31:25 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Wed Feb 22 13:31:25 2012 +0100

----------------------------------------------------------------------
 server/lib/deltacloud/backend_capability.rb     |   11 +----------
 server/lib/deltacloud/base_driver/exceptions.rb |    6 ++++++
 2 files changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/0d319291/server/lib/deltacloud/backend_capability.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/backend_capability.rb b/server/lib/deltacloud/backend_capability.rb
index 57e8cd3..7f19007 100644
--- a/server/lib/deltacloud/backend_capability.rb
+++ b/server/lib/deltacloud/backend_capability.rb
@@ -16,15 +16,6 @@
 
 module Deltacloud::BackendCapability
 
-  class Failure < StandardError
-    attr_reader :capability
-
-    def initialize(capability, msg='')
-      super(msg)
-      @capability = capability
-    end
-  end
-
   attr_reader :capability
 
   def with_capability(capability)
@@ -37,7 +28,7 @@ module Deltacloud::BackendCapability
 
   def check_capability(backend)
     if !has_capability?(backend)
-      raise Failure.new(capability, "#{capability} capability not supported by backend #{backend.class.name}")
+      raise Deltacloud::ExceptionHandler::NotSupported.new("#{capability} capability not
supported by backend #{backend.class.name}")
     end
   end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/0d319291/server/lib/deltacloud/base_driver/exceptions.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/base_driver/exceptions.rb b/server/lib/deltacloud/base_driver/exceptions.rb
index e44c89b..0c66659 100644
--- a/server/lib/deltacloud/base_driver/exceptions.rb
+++ b/server/lib/deltacloud/base_driver/exceptions.rb
@@ -79,6 +79,12 @@ module Deltacloud
       end
     end
 
+    class NotSupported < DeltacloudException
+      def initialize(message)
+        super(501, self.class.name, message, self.backtrace)
+      end
+    end
+
     class ExceptionDef
       attr_accessor :status
       attr_accessor :message


Mime
View raw message