Sha256: 9ce62d6d7fe4889bbdc245e8e5d2c9bfd42d6aa760276ad7194107ebcaa2d107

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module SwiftypeAppSearch
  class ClientException < StandardError
    attr_reader :errors

    def initialize(response)
      @errors = response['errors'] || [ response ]
      message = (errors.count == 1) ? "Error: #{errors.first}" : "Errors: #{errors.inspect}"
      super(message)
    end
  end

  class NonExistentRecord < ClientException; end
  class InvalidCredentials < ClientException; end
  class BadRequest < ClientException; end
  class Forbidden < ClientException; end
  class InvalidDocument < ClientException; end

  class UnexpectedHTTPException < ClientException
    def initialize(http_response)
      @errors = []
      super("HTTP #{http_response.code}: #{http_response.body}")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swiftype-app-search-0.1.0 lib/swiftype-app-search/exceptions.rb