Exception: Telesign::API::APIError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/telesign/rest.rb

Direct Known Subclasses

AuthError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ APIError



156
157
158
159
160
161
162
# File 'lib/telesign/rest.rb', line 156

def initialize(http_response)

  @errors = JSON.parse(http_response.body)['errors']
  @headers = http_response.to_hash
  @status = http_response.code
  @body = http_response.body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



154
155
156
# File 'lib/telesign/rest.rb', line 154

def body
  @body
end

#errorsObject

Returns the value of attribute errors.



154
155
156
# File 'lib/telesign/rest.rb', line 154

def errors
  @errors
end

#headersObject

Returns the value of attribute headers.



154
155
156
# File 'lib/telesign/rest.rb', line 154

def headers
  @headers
end

#statusObject

Returns the value of attribute status.



154
155
156
# File 'lib/telesign/rest.rb', line 154

def status
  @status
end

Instance Method Details

#to_sObject



164
165
166
167
168
169
170
171
# File 'lib/telesign/rest.rb', line 164

def to_s
  result = ''
  @errors.each do |error|
    result = "#{result}#{error['description']}\n"
  end

  result
end