Sha256: 81923296000ffb4b366f76cd208f94ffb5be0bd7536a5d2c1120935d79d568ea

Contents?: true

Size: 1.17 KB

Versions: 70

Compression:

Stored size: 1.17 KB

Contents

module Fog
  module OpenStack
    module Errors
      class ServiceError < Fog::Errors::Error
        attr_reader :response_data

        def self.slurp(error)
          if error.response.body.empty?
            data = nil
            message = nil
          else
            data = Fog::JSON.decode(error.response.body)
            message = data['message']
            if message.nil? and !data.values.first.nil?
              message = data.values.first['message']
            end
          end

          new_error = super(error, message)
          new_error.instance_variable_set(:@response_data, data)
          new_error
        end
      end

      class ServiceUnavailable < ServiceError; end

      class BadRequest < ServiceError
        attr_reader :validation_errors

        def self.slurp(error)
          new_error = super(error)
          unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
            new_error.instance_variable_set(:@validation_errors, new_error.response_data['badRequest']['validationErrors'])
          end
          new_error
        end
      end

      class InterfaceNotImplemented < Fog::Errors::Error; end
    end
  end
end

Version data entries

70 entries across 68 versions & 5 rubygems

Version Path
fog-openstack-0.3.8 lib/fog/openstack/errors.rb
fog-openstack-0.3.7 lib/fog/openstack/errors.rb
fog-openstack-1.0.4 lib/fog/openstack/errors.rb
fog-openstack-0.3.6 lib/fog/openstack/errors.rb
fog-openstack-1.0.3 lib/fog/openstack/errors.rb
fog-openstack-1.0.2 lib/fog/openstack/errors.rb
fog-openstack-0.3.5 lib/fog/openstack/errors.rb
fog-openstack-0.3.4 lib/fog/openstack/errors.rb
fog-openstack-1.0.1 lib/fog/openstack/errors.rb
fog-openstack-0.3.3 lib/fog/openstack/errors.rb
fog-openstack-1.0.0 lib/fog/openstack/errors.rb
fog-openstack-0.3.2 lib/fog/openstack/errors.rb
fog-openstack-0.3.1 lib/fog/openstack/errors.rb
fog-openstack-0.3.0 lib/fog/openstack/errors.rb
fog-openstack-0.2.4 lib/fog/openstack/errors.rb
fog-openstack-0.2.3 lib/fog/openstack/errors.rb
fog-openstack-0.2.2 lib/fog/openstack/errors.rb
fog-openstack-0.2.1 lib/fog/openstack/errors.rb
fog-openstack-0.2.0 lib/fog/openstack/errors.rb
fog-zj-0.1.28 lib/fog/openstack/errors.rb