Exception: Vonage::APIError

Inherits:
Error
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/vonage/api_error.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_response: nil) ⇒ APIError

Returns a new instance of APIError.



12
13
14
15
# File 'lib/vonage/api_error.rb', line 12

def initialize(message = nil, http_response: nil)
  super(message)
  @http_response = http_response
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



9
10
11
# File 'lib/vonage/api_error.rb', line 9

def http_response
  @http_response
end

Instance Method Details

#http_response_bodyObject



27
28
29
30
31
# File 'lib/vonage/api_error.rb', line 27

def http_response_body
  return nil unless http_response
  return {} unless http_response.content_type && http_response.content_type.include?("json")
  ::JSON.parse(http_response.body)
end

#http_response_codeObject



17
18
19
20
# File 'lib/vonage/api_error.rb', line 17

def http_response_code
  return nil unless http_response
  http_response.code
end

#http_response_headersObject



22
23
24
25
# File 'lib/vonage/api_error.rb', line 22

def http_response_headers
  return nil unless http_response
  http_response.to_hash
end