Class: PaypalServerSdk::ErrorException
- Inherits:
-
APIException
- Object
- CoreLibrary::ApiException
- APIException
- PaypalServerSdk::ErrorException
- Defined in:
- lib/paypal_server_sdk/exceptions/error_exception.rb
Overview
The error details.
Instance Attribute Summary collapse
-
#debug_id ⇒ String
The PayPal internal ID.
-
#details ⇒ Array[ErrorDetails]
An array of additional details about the error.
-
#links ⇒ Array[LinkDescription]
An array of request-related [HATEOAS links](/api/rest/responses/#hateoas-links).
-
#message ⇒ String
The message that describes the error.
-
#name ⇒ String
The human-readable, unique name of the error.
Instance Method Summary collapse
-
#initialize(reason, response) ⇒ ErrorException
constructor
The constructor.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, response) ⇒ ErrorException
The constructor.
36 37 38 39 40 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 36 def initialize(reason, response) super(reason, response) hash = APIHelper.json_deserialize(@response.raw_body) unbox(hash) end |
Instance Attribute Details
#debug_id ⇒ String
The PayPal internal ID. Used for correlation purposes.
22 23 24 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 22 def debug_id @debug_id end |
#details ⇒ Array[ErrorDetails]
An array of additional details about the error.
26 27 28 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 26 def details @details end |
#links ⇒ Array[LinkDescription]
An array of request-related [HATEOAS links](/api/rest/responses/#hateoas-links).
31 32 33 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 31 def links @links end |
#message ⇒ String
The message that describes the error.
18 19 20 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 18 def @message end |
#name ⇒ String
The human-readable, unique name of the error.
14 15 16 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 14 def name @name end |
Instance Method Details
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/paypal_server_sdk/exceptions/error_exception.rb', line 45 def unbox(hash) @name = hash.key?('name') ? hash['name'] : nil @message = hash.key?('message') ? hash['message'] : nil @debug_id = hash.key?('debug_id') ? hash['debug_id'] : nil # Parameter is an array, so we need to iterate through it @details = nil unless hash['details'].nil? @details = [] hash['details'].each do |structure| @details << (ErrorDetails.from_hash(structure) if structure) end end @details = SKIP unless hash.key?('details') # Parameter is an array, so we need to iterate through it @links = nil unless hash['links'].nil? @links = [] hash['links'].each do |structure| @links << (LinkDescription.from_hash(structure) if structure) end end @links = SKIP unless hash.key?('links') end |