Exception: SwiftypeAppSearch::ClientException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/swiftype-app-search/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ClientException

Returns a new instance of ClientException.



5
6
7
8
9
10
11
12
13
# File 'lib/swiftype-app-search/exceptions.rb', line 5

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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/swiftype-app-search/exceptions.rb', line 3

def errors
  @errors
end