Exception: KillBillClient::API::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/killbill_client/api/errors.rb

Overview

The superclass to all errors that occur when making an API request.

Direct Known Subclasses

ClientError, NotModified, Redirection, ServerError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#set_message

Constructor Details

#initialize(request, response) ⇒ ResponseError

Returns a new instance of ResponseError.



10
11
12
# File 'lib/killbill_client/api/errors.rb', line 10

def initialize(request, response)
  @request, @response = request, response
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/killbill_client/api/errors.rb', line 7

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



8
9
10
# File 'lib/killbill_client/api/errors.rb', line 8

def response
  @response
end

Class Method Details

.error_for(status, request, response) ⇒ Object



29
30
31
# File 'lib/killbill_client/api/errors.rb', line 29

def self.error_for(status, request, response)
  ERRORS[status].new(request, response)
end

Instance Method Details

#codeObject



14
15
16
# File 'lib/killbill_client/api/errors.rb', line 14

def code
  response.code.to_i if response and response.code
end

#to_sObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/killbill_client/api/errors.rb', line 18

def to_s
  if description
    return CGI.unescapeHTML description
  end

  return super unless code
  '%d %s (%s %s)' % [
      code, http_error, request.method, API.base_uri + request.path
  ]
end