Exception: Rentvine::RentvineError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rentvine/rentvine_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ RentvineError

Returns a new instance of RentvineError.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rentvine/rentvine_error.rb', line 9

def initialize(http_response)
  @raw = http_response
  @response_code = @raw.response_code

  data = process_response_body
  if data.nil?
    set_default_error_message
  else
    @error = data
  end
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/rentvine/rentvine_error.rb', line 5

def error
  @error
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/rentvine/rentvine_error.rb', line 6

def raw
  @raw
end

#response_codeObject (readonly)

Returns the value of attribute response_code.



7
8
9
# File 'lib/rentvine/rentvine_error.rb', line 7

def response_code
  @response_code
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/rentvine/rentvine_error.rb', line 21

def error?
  true
end

#to_sObject Also known as: message



25
26
27
28
29
30
31
32
33
34
# File 'lib/rentvine/rentvine_error.rb', line 25

def to_s
  return remove_extra_quotes(@error) if @error.is_a?(String)

  retval = @error.each_with_object([]) do |(key, value), str|
    str_value = value.is_a?(Array) ? value.join(', ') : value
    str_value = remove_extra_quotes(str_value)
    str << "#{key}: #{str_value}"
  end
  retval.join(', ')
end