lib/paypal-api/error.rb in paypal-rest-api-0.3.1 vs lib/paypal-api/error.rb in paypal-rest-api-0.4.0
- old
+ new
@@ -35,20 +35,22 @@
#
# Raised when PayPal responds with any status code except 200, 201, 202, 204
#
class FailedRequest < Error
def initialize(message = nil, request:, response:)
- super(message)
@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
end
#
# Raised when a network raised when executing the request