Exception: Pago::APIError

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

Overview

Raised when the API answered with a non 2xx status code.

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

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(message = nil, status_code: nil, data: nil, body: nil, response: nil)
  @status_code = status_code
  @data = data
  @body = body
  @response = response
  super(message || "Pago API returned an error: #{status_code}")
end

Instance Attribute Details

#bodyObject? (readonly)

Returns the raw parsed body of the response.

Returns:

  • (Object, nil)

    the raw parsed body of the response.



23
24
25
# File 'lib/pago/errors.rb', line 23

def body
  @body
end

#dataObject? (readonly)

Returns the deserialized error payload, when the endpoint declares one.

Returns:

  • (Object, nil)

    the deserialized error payload, when the endpoint declares one.



21
22
23
# File 'lib/pago/errors.rb', line 21

def data
  @data
end

#responsePago::HTTP::Response? (readonly)

Returns the raw HTTP response.

Returns:



25
26
27
# File 'lib/pago/errors.rb', line 25

def response
  @response
end

#status_codeInteger (readonly)

Returns the HTTP status code of the response.

Returns:

  • (Integer)

    the HTTP status code of the response.



19
20
21
# File 'lib/pago/errors.rb', line 19

def status_code
  @status_code
end