incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH core] Client: Added error handler for 502 code
Date Tue, 11 Oct 2011 10:57:25 GMT
ACK

On 11/10/11 13:17, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mfojtik@redhat.com>
> 
> 
> Signed-off-by: Michal fojtik <mfojtik@redhat.com>
> ---
>  client/lib/deltacloud.rb |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
> index fcf6e49..55cd854 100644
> --- a/client/lib/deltacloud.rb
> +++ b/client/lib/deltacloud.rb
> @@ -359,7 +359,7 @@ module DeltaCloud
>        if conf[:method].eql?(:post)
>          resource = RestClient::Resource.new(conf[:path], :open_timeout => conf[:open_timeout],
:timeout => conf[:timeout])
>          resource.send(:post, conf[:form_data], default_headers.merge(extended_headers))
do |response, request, block|
> -          handle_backend_error(response) if response.code.eql?(500)
> +          handle_backend_error(response) if [500, 502].include? response.code
>            if response.respond_to?('body')
>              yield response.body if block_given?
>            else
> @@ -369,7 +369,7 @@ module DeltaCloud
>        else
>          resource = RestClient::Resource.new(conf[:path], :open_timeout => conf[:open_timeout],
:timeout => conf[:timeout])
>          resource.send(conf[:method], default_headers.merge(extended_headers)) do |response,
request, block|
> -          handle_backend_error(response) if response.code.eql?(500)
> +          handle_backend_error(response) if [500, 502].include? response.code
>            if conf[:method].eql?(:get) and [301, 302, 307].include? response.code
>              response.follow_redirection(request) do |response, request, block|
>                if response.respond_to?('body')
> @@ -393,7 +393,7 @@ module DeltaCloud
>      # backend
>      class BackendError < StandardError
>        def initialize(opts={})
> -        @message = opts[:message]
> +        @message = "[#{opts[:code]}] #{opts[:message]}"
>        end
>        def message
>          @message
> @@ -401,7 +401,7 @@ module DeltaCloud
>      end
>  
>      def handle_backend_error(response)
> -      raise BackendError.new(:message => (Nokogiri::XML(response)/'error/message').text)
> +      raise BackendError.new(:message => (Nokogiri::XML(response)/'error/message').text,
:code => response.code)
>      end
>  
>      # Check if specified collection have wanted feature


Mime
View raw message