Sha256: 54b08c071d01d9e7d4d3f714f0e5ba29ea611da8f63c0f3dfaa0b070fbc0c445
Contents?: true
Size: 992 Bytes
Versions: 2
Compression:
Stored size: 992 Bytes
Contents
module Elastic module AppSearch class ClientException < StandardError attr_reader :errors def initialize(response) @errors = if response.is_a?(Array) response.flat_map { |r| r['errors'] } else response['errors'] || [response] end 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 RequestEntityTooLarge < ClientException; end class UnexpectedHTTPException < ClientException def initialize(response, response_json) errors = (response_json['errors'] || [response.message]).map { |e| "(#{response.code}) #{e}" } super({ 'errors' => errors }) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elastic-app-search-7.3.0 | lib/elastic/app-search/exceptions.rb |
elastic-app-search-0.7.0 | lib/elastic/app-search/exceptions.rb |