Class: Plaid::ErrorErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/plaid/exceptions/error_error_exception.rb

Overview

We use standard HTTP response codes for success and failure notifications, and our errors are further classified by ‘error_type`. In general, 200 HTTP codes correspond to success, 40X codes are for developer- or user-related failures, and 50X codes are for Plaid-related issues. Error fields will be `null` if no error has occurred.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ ErrorErrorException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



65
66
67
68
69
# File 'lib/plaid/exceptions/error_error_exception.rb', line 65

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

Instance Attribute Details

#causesArray[Object]

In the Assets product, a request can pertain to more than one Item. If an error is returned for such a request, ‘causes` will return an array of errors containing a breakdown of these errors on the individual Item level, if any can be identified. `causes` will only be provided for the `error_type` `ASSET_REPORT_ERROR`.

Returns:

  • (Array[Object])


46
47
48
# File 'lib/plaid/exceptions/error_error_exception.rb', line 46

def causes
  @causes
end

#display_messageString

A user-friendly representation of the error code. ‘null` if the error is not related to user action. This may change over time and is not safe for programmatic use.

Returns:

  • (String)


33
34
35
# File 'lib/plaid/exceptions/error_error_exception.rb', line 33

def display_message
  @display_message
end

#documentation_urlString

The URL of a Plaid documentation page with more information about the error

Returns:

  • (String)


56
57
58
# File 'lib/plaid/exceptions/error_error_exception.rb', line 56

def documentation_url
  @documentation_url
end

#error_codeString

The particular error code. Safe for programmatic use.

Returns:

  • (String)


22
23
24
# File 'lib/plaid/exceptions/error_error_exception.rb', line 22

def error_code
  @error_code
end

#error_messageString

A developer-friendly representation of the error code. This may change over time and is not safe for programmatic use.

Returns:

  • (String)


27
28
29
# File 'lib/plaid/exceptions/error_error_exception.rb', line 27

def error_message
  @error_message
end

#error_typeErrorType

A broad categorization of the error. Safe for programatic use.

Returns:



18
19
20
# File 'lib/plaid/exceptions/error_error_exception.rb', line 18

def error_type
  @error_type
end

#request_idString

A unique ID identifying the request, to be used for troubleshooting purposes. This field will be omitted in errors provided by webhooks.

Returns:

  • (String)


38
39
40
# File 'lib/plaid/exceptions/error_error_exception.rb', line 38

def request_id
  @request_id
end

#statusFloat

The HTTP status code associated with the error. This will only be returned in the response body when the error information is provided via a webhook.

Returns:

  • (Float)


51
52
53
# File 'lib/plaid/exceptions/error_error_exception.rb', line 51

def status
  @status
end

#suggested_actionString

Suggested steps for resolving the error

Returns:

  • (String)


60
61
62
# File 'lib/plaid/exceptions/error_error_exception.rb', line 60

def suggested_action
  @suggested_action
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



101
102
103
104
105
106
107
108
# File 'lib/plaid/exceptions/error_error_exception.rb', line 101

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_type: #{@error_type.inspect}, error_code: #{@error_code.inspect},"\
  " error_message: #{@error_message.inspect}, display_message: #{@display_message.inspect},"\
  " request_id: #{@request_id.inspect}, causes: #{@causes.inspect}, status:"\
  " #{@status.inspect}, documentation_url: #{@documentation_url.inspect}, suggested_action:"\
  " #{@suggested_action.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



92
93
94
95
96
97
98
# File 'lib/plaid/exceptions/error_error_exception.rb', line 92

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} error_type: #{@error_type}, error_code: #{@error_code}, error_message:"\
  " #{@error_message}, display_message: #{@display_message}, request_id: #{@request_id},"\
  " causes: #{@causes}, status: #{@status}, documentation_url: #{@documentation_url},"\
  " suggested_action: #{@suggested_action}>"
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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/plaid/exceptions/error_error_exception.rb', line 74

def unbox(hash)
  return nil unless hash

  @error_type = hash.key?('error_type') ? hash['error_type'] : nil
  @error_code = hash.key?('error_code') ? hash['error_code'] : nil
  @error_message = hash.key?('error_message') ? hash['error_message'] : nil
  @display_message =
    hash.key?('display_message') ? hash['display_message'] : nil
  @request_id = hash.key?('request_id') ? hash['request_id'] : SKIP
  @causes = hash.key?('causes') ? hash['causes'] : SKIP
  @status = hash.key?('status') ? hash['status'] : SKIP
  @documentation_url =
    hash.key?('documentation_url') ? hash['documentation_url'] : SKIP
  @suggested_action =
    hash.key?('suggested_action') ? hash['suggested_action'] : SKIP
end