Sha256: 61da5f90b7dd1269b91002a735a32f1a64ea25a746265aff2121cd24b2c43ad5

Contents?: true

Size: 1.18 KB

Versions: 51

Compression:

Stored size: 1.18 KB

Contents

module Fog
  module CloudSigma
    module Errors
      class Error < Fog::Errors::Error
        attr_accessor :type, :error_point

        def initialize(message, type='n/a', error_point=nil)
          @type = type
          @error_point = error_point
          super(message)
        end

      end

      class NotFound < Error; end
      class RequestError < Error; end
      class ServerError < Error; end

      def self.slurp_http_status_error(error)
        error_class =  case error.response[:status]
                         when 404
                           NotFound
                         when 500..599
                           ServerError
                         when 400..499
                           RequestError
                         else
                           Error
                       end

        new_error = error_class.new(error.response[:body].first['error_message'],
                                    error.response[:body].first['error_type'],
                                    error.response[:body].first['error_point'])
        new_error.set_backtrace(error.backtrace)
        new_error.verbose = error.message
        new_error
      end



    end


  end
end

Version data entries

51 entries across 51 versions & 3 rubygems

Version Path
fog-maestrodev-1.20.0.20140305101839 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/cloudsigma/error.rb
fog-1.20.0 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/cloudsigma/error.rb
fog-1.19.0 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/cloudsigma/error.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/cloudsigma/error.rb