Exception: Elastics::HttpError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/elastics/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, caller_line = nil) ⇒ HttpError

Returns a new instance of HttpError.



18
19
20
21
# File 'lib/elastics/errors.rb', line 18

def initialize(response, caller_line=nil)
  @response    = response
  @caller_line = caller_line
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



16
17
18
# File 'lib/elastics/errors.rb', line 16

def response
  @response
end

Instance Method Details

#bodyObject



27
28
29
# File 'lib/elastics/errors.rb', line 27

def body
  response.body
end

#statusObject



23
24
25
# File 'lib/elastics/errors.rb', line 23

def status
  response.status
end

#to_hashObject



36
37
38
39
40
# File 'lib/elastics/errors.rb', line 36

def to_hash
  MultiJson.decode response.body
rescue MultiJson::DecodeError
  {}
end

#to_sObject



31
32
33
34
# File 'lib/elastics/errors.rb', line 31

def to_s
  log = "#@caller_line\n" if @caller_line
  "#{log}#{status}: #{body}"
end