Exception: Pago::APIError
Overview
Raised when the API answered with a non 2xx status code.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object?
readonly
The raw parsed body of the response.
-
#data ⇒ Object?
readonly
The deserialized error payload, when the endpoint declares one.
-
#response ⇒ Pago::HTTP::Response?
readonly
The raw HTTP response.
-
#status_code ⇒ Integer
readonly
The HTTP status code of the response.
Instance Method Summary collapse
-
#initialize(message = nil, status_code: nil, data: nil, body: nil, response: nil) ⇒ APIError
constructor
A new instance of APIError.
Constructor Details
#initialize(message = nil, status_code: nil, data: nil, body: nil, response: nil) ⇒ APIError
Returns a new instance of APIError.
27 28 29 30 31 32 33 |
# File 'lib/pago/errors.rb', line 27 def initialize( = nil, status_code: nil, data: nil, body: nil, response: nil) @status_code = status_code @data = data @body = body @response = response super( || "Pago API returned an error: #{status_code}") end |
Instance Attribute Details
#body ⇒ Object? (readonly)
Returns the raw parsed body of the response.
23 24 25 |
# File 'lib/pago/errors.rb', line 23 def body @body end |
#data ⇒ Object? (readonly)
Returns the deserialized error payload, when the endpoint declares one.
21 22 23 |
# File 'lib/pago/errors.rb', line 21 def data @data end |
#response ⇒ Pago::HTTP::Response? (readonly)
Returns the raw HTTP response.
25 26 27 |
# File 'lib/pago/errors.rb', line 25 def response @response end |
#status_code ⇒ Integer (readonly)
Returns the HTTP status code of the response.
19 20 21 |
# File 'lib/pago/errors.rb', line 19 def status_code @status_code end |