Exception: PaypalAPI::Errors::FailedRequest

Inherits:
PaypalAPI::Error show all
Defined in:
lib/paypal-api/error.rb

Overview

Raised when PayPal responds with any status code except 200, 201, 202, 204

Instance Attribute Summary

Attributes inherited from PaypalAPI::Error

#error_debug_id, #error_details, #error_message, #error_name, #paypal_request_id, #request, #response

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, request:, response:) ⇒ FailedRequest

Returns a new instance of FailedRequest.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/paypal-api/error.rb', line 39

def initialize(message = nil, request:, response:)
  @request = request
  @response = response

  body = response.body
  data = body.is_a?(Hash) ? body : {}
  @error_name = data[:name] || data[:error] || response.http_response.class.name
  @error_message = data[:message] || data[:error_description] || response.http_body.to_s
  @error_debug_id = data[:debug_id]
  @error_details = data[:details]
  @paypal_request_id = request.http_request["paypal-request-id"]

  message += "\n  #{response.http_body}" unless data.empty?
  super(message)
end