Sha256: b40bd1e502f58a284e6ee81e787fc0301d2ac06ea25e502dce994c301c5cf9b4

Contents?: true

Size: 1.17 KB

Versions: 39

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

39 entries across 39 versions & 3 rubygems

Version Path
fog-maestrodev-1.19.0.20140212012611 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/rackspace/errors.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/rackspace/errors.rb
fog-1.19.0 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/rackspace/errors.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/rackspace/errors.rb