You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by tc...@redhat.com on 2010/12/09 13:52:19 UTC

[PATCH client] BackendError now inherits from StandardError instead of Exception

From: Tobias Crawley <tc...@redhat.com>

This allows the errors to be caught by 'naked' rescue blocks, and allows
the AASM gem's error handling mechanism to properly handle BackendErrors,
since it explicitly rescues StandardError.
---
 client/lib/deltacloud.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index c632594..2c64e65 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -287,7 +287,7 @@ module DeltaCloud
 
     # Re-raise backend errors as on exception in client with message from
     # backend
-    class BackendError < Exception
+    class BackendError < StandardError
       def initialize(opts={})
         @message = opts[:message]
       end
-- 
1.7.3.2


Re: [PATCH client] BackendError now inherits from StandardError instead of Exception

Posted by Michal Fojtik <mf...@redhat.com>.
On 09/12/10 07:52 -0500, tcrawley@redhat.com wrote:
>From: Tobias Crawley <tc...@redhat.com>
>
>This allows the errors to be caught by 'naked' rescue blocks, and allows
>the AASM gem's error handling mechanism to properly handle BackendErrors,
>since it explicitly rescues StandardError.

ACK. Good catch.

  -- Michal

>---
> client/lib/deltacloud.rb |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
>diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
>index c632594..2c64e65 100644
>--- a/client/lib/deltacloud.rb
>+++ b/client/lib/deltacloud.rb
>@@ -287,7 +287,7 @@ module DeltaCloud
>
>     # Re-raise backend errors as on exception in client with message from
>     # backend
>-    class BackendError < Exception
>+    class BackendError < StandardError
>       def initialize(opts={})
>         @message = opts[:message]
>       end
>--
>1.7.3.2
>

-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------