On Wed, 2010-07-28 at 12:21 +0200, [email protected] wrote:
> ---
>  server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |   36 +++++----
>  .../lib/deltacloud/drivers/gogrid/gogrid_driver.rb |    2 +-
>  .../drivers/rackspace/rackspace_driver.rb          |   66 +++++++++++------
>  .../drivers/rimuhosting/rimuhosting_driver.rb      |   74 ++++++++++++-------
>  .../drivers/terremark/terremark_driver.rb          |   80 
> +++++++++++++-------
>  server/views/errors/backend_error.html.haml        |    4 +-
>  6 files changed, 167 insertions(+), 95 deletions(-)

ACK with a couple minor nits:

> diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb 
> b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> index 6a9c8d2..0dc1733 100644
> --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> @@ -144,6 +158,14 @@ class RackspaceDriver < Deltacloud::BaseDriver
>      stopped.to( :finish )         .automatically
>    end
>  
> +  def safely(&block)
> +    begin
> +      block.call
> +    rescue Exception => e
> +      raise Deltacloud::BackendError.new(500, e.class.to_s, e.message, 
> e.backtrace)
> +    end
> +  end
> +
>  end

There are several identicaly implementations of safely now, they should
be lifted into BaseDriver.

Also, it would be better if safely took a list of classes and only
turned exceptions of a subclass of one of the classes into
BackendError's, so that we don't obscure the difference between a true
internal server error (because of a problem in the Deltacloud code) vs.
an error from the backend.

David


Reply via email to