Module: Fog::Rackspace::Errors

Included in:
Compute::Rackspace, Compute::RackspaceV2, DNS::Rackspace, BlockStorage, Databases, LoadBalancers, Storage::Rackspace
Defined in:
lib/fog/rackspace.rb,
lib/fog/rackspace/errors.rb

Defined Under Namespace

Classes: BadRequest, Conflict, InternalServerError, ServiceError, ServiceUnavailable

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/rackspace/errors.rb', line 5

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

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

      def self.slurp(error, region=nil)
        exception = NotFound.new
        exception.instance_variable_set(:@region, region)
        exception.instance_variable_set(:@status_code, error.response.status) rescue nil
        exception
      end
    end
  EOS
end