Exception: Rentvine::RentvineError
- Inherits:
-
StandardError
- Object
- StandardError
- Rentvine::RentvineError
- Defined in:
- lib/rentvine/rentvine_error.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#response_code ⇒ Object
readonly
Returns the value of attribute response_code.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(http_response) ⇒ RentvineError
constructor
A new instance of RentvineError.
- #to_s ⇒ Object (also: #message)
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? else @error = data end end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
5 6 7 |
# File 'lib/rentvine/rentvine_error.rb', line 5 def error @error end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/rentvine/rentvine_error.rb', line 6 def raw @raw end |
#response_code ⇒ Object (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
21 22 23 |
# File 'lib/rentvine/rentvine_error.rb', line 21 def error? true end |
#to_s ⇒ Object 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 |