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-1.1.3 lib/fog/openstack/errors.rb
fog-openstack-1.1.2 lib/fog/openstack/errors.rb
fog-openstack-fork-99 lib/fog/openstack/errors.rb
fog-openstack-1.1.0 lib/fog/openstack/errors.rb
fog-openstack-1.1.0.pre lib/fog/openstack/errors.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/errors.rb
fog-openstack-1.0.11 lib/fog/openstack/errors.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/errors.rb
fog-openstack-1.0.10 lib/fog/openstack/errors.rb
fog-openstack-1.0.9 lib/fog/openstack/errors.rb
fog-openstack-0.1.31 lib/fog/openstack/errors.rb
fog-openstack-0.3.10 lib/fog/openstack/errors.rb
fog-openstack-1.0.8 lib/fog/openstack/errors.rb
fog-openstack-0.1.30 lib/fog/openstack/errors.rb
fog-openstack-1.0.7 lib/fog/openstack/errors.rb
fog-openstack-0.1.29 lib/fog/openstack/errors.rb
fog-openstack-0.3.9 lib/fog/openstack/errors.rb
fog-openstack-1.0.6 lib/fog/openstack/errors.rb
fog-openstack-0.1.28 lib/fog/openstack/errors.rb
fog-openstack-1.0.5 lib/fog/openstack/errors.rb