Class: PaypalServerSdk::DefaultErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/paypal_server_sdk/exceptions/default_error_exception.rb

Overview

The error details.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ DefaultErrorException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



41
42
43
44
45
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 41

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#debug_idString

The PayPal internal ID. Used for correlation purposes.

Returns:

  • (String)


22
23
24
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 22

def debug_id
  @debug_id
end

#detailsArray[TransactionSearchErrorDetails]

An array of additional details about the error.

Returns:



31
32
33
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 31

def details
  @details
end

The information link, or URI, that shows detailed information about this error for the developer.

Returns:

  • (String)


27
28
29
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 27

def information_link
  @information_link
end

An array of request-related [HATEOAS links](/docs/api/reference/api-responses/#hateoas-links).

Returns:



36
37
38
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 36

def links
  @links
end

#messageString

The message that describes the error.

Returns:

  • (String)


18
19
20
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 18

def message
  @message
end

#nameString

The human-readable, unique name of the error.

Returns:

  • (String)


14
15
16
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 14

def name
  @name
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



88
89
90
91
92
93
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 88

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name.inspect}, message: #{@message.inspect}, debug_id:"\
  " #{@debug_id.inspect}, information_link: #{@information_link.inspect}, details:"\
  " #{@details.inspect}, links: #{@links.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
85
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} name: #{@name}, message: #{@message}, debug_id: #{@debug_id},"\
  " information_link: #{@information_link}, details: #{@details}, links: #{@links}>"
end

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • hash (Hash)

    The deserialized response sent by the server in the



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/paypal_server_sdk/exceptions/default_error_exception.rb', line 50

def unbox(hash)
  return nil unless 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
  @information_link =
    hash.key?('information_link') ? hash['information_link'] : SKIP
  # Parameter is an array, so we need to iterate through it

  @details = nil
  unless hash['details'].nil?
    @details = []
    hash['details'].each do |structure|
      @details << (TransactionSearchErrorDetails.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