Exception: Invoicexpress::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/invoicexpress/error.rb

Overview

Custom error class for rescuing from all Invoicexpress errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response = nil) ⇒ Error

Returns a new instance of Error.



18
19
20
21
22
23
# File 'lib/invoicexpress/error.rb', line 18

def initialize(response=nil)
  @response = response
  @messages = []

  super(build_error_message)
end

Instance Attribute Details

#messagesObject

Returns the value of attribute messages.



16
17
18
# File 'lib/invoicexpress/error.rb', line 16

def messages
  @messages
end

Instance Method Details

#response_bodyObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/invoicexpress/error.rb', line 25

def response_body
  @response_body ||=
    if (body = @response[:body]) && !body.empty?
      if body.is_a?(String) and body.start_with?("<")
        Invoicexpress::Models::Errors.parse(body)
      else
        body
      end
    else
      nil
    end
end