Sha256: 936865e0f629fe5fa212619e84aca448c482ba247b2f50ba4010930a1184535a

Contents?: true

Size: 1.17 KB

Versions: 31

Compression:

Stored size: 1.17 KB

Contents

module Fog
  module Rackspace
    module Errors
      def self.included(mod)
        mod.class_eval <<-'EOS', __FILE__, __LINE__
          class NotFound < Fog::Service::NotFound
            attr_reader :region, :status_code, :transaction_id

            def to_s
              status = status_code ? "HTTP #{status_code}" : "HTTP <Unknown>"
              message = region ? "resource not found in #{region} region" : super
              "[#{status} | #{transaction_id}] #{message}"
            end

            def self.slurp(error, service=nil)
              exception = NotFound.new
              exception.instance_variable_set(:@region, service.region) if service && service.respond_to?(:region)
              exception.instance_variable_set(:@status_code, error.response.status) rescue nil
              exception.set_transaction_id(error, service)
              exception
            end

            def set_transaction_id(error, service)
              return unless service && service.respond_to?(:request_id_header) && error.response
              @transaction_id = error.response.headers[service.request_id_header]
            end

          end
        EOS
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
fog-rackspace-0.1.1 lib/fog/rackspace/errors.rb
fog-rackspace-0.1.0 lib/fog/rackspace/errors.rb
fog-1.37.0 lib/fog/rackspace/errors.rb
fog-1.36.0 lib/fog/rackspace/errors.rb
fog-1.35.0 lib/fog/rackspace/errors.rb
fog-2.0.0.pre.0 lib/fog/rackspace/errors.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/errors.rb
fog-1.34.0 lib/fog/rackspace/errors.rb
fog-1.33.0 lib/fog/rackspace/errors.rb
fog-1.32.0 lib/fog/rackspace/errors.rb
fog-1.31.0 lib/fog/rackspace/errors.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rackspace/errors.rb
fog-1.30.0 lib/fog/rackspace/errors.rb
fog-1.29.0 lib/fog/rackspace/errors.rb
fog-1.28.0 lib/fog/rackspace/errors.rb
fog-1.27.0 lib/fog/rackspace/errors.rb
fog-1.26.0 lib/fog/rackspace/errors.rb
fog-1.25.0 lib/fog/rackspace/errors.rb
nsidc-fog-1.24.1 lib/fog/rackspace/errors.rb
fog-1.24.0 lib/fog/rackspace/errors.rb