Exception: Attio::Error

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

Overview

Base error class for all Attio errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, response = nil) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/attio/errors.rb', line 8

def initialize(message, response = nil)
  @response = response

  if response
    @code = response[:status]
    @request_id = extract_request_id(response)

    # Try to extract a better error message from the response
    if response[:body].is_a?(Hash)
      api_message = response[:body][:error] || response[:body][:message]
      message = "#{message}: #{api_message}" if api_message
    end
  end

  super(message)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/attio/errors.rb', line 6

def code
  @code
end

#request_idObject (readonly)

Returns the value of attribute request_id.



6
7
8
# File 'lib/attio/errors.rb', line 6

def request_id
  @request_id
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/attio/errors.rb', line 6

def response
  @response
end