Class: ThePlaidApi::ErrorErrorException

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

Overview

Errors are identified by ‘error_code` and categorized by `error_type`. Use these in preference to HTTP status codes to identify and handle specific errors. HTTP status codes are set and provide the broadest categorization of errors: 4xx codes are for developer- or user-related errors, and 5xx codes are for Plaid-related errors, and the status will be 2xx in non-error cases. An Item with a non-`null` error object will only be part of an API response when calling `/item/get` to view Item status. Otherwise, error fields will be `null` if no error has occurred; if an error has occurred, an error code will be returned instead.

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.



98
99
100
101
102
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 98

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

Instance Attribute Details

#causesArray[Object]

In this 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 be provided for the `error_type` `ASSET_REPORT_ERROR` or `CHECK_REPORT_ERROR`. `causes` will also not be populated inside an error nested within a `warning` object.

Returns:

  • (Array[Object])


65
66
67
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 65

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)


50
51
52
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 50

def display_message
  @display_message
end

#documentation_urlString

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

Returns:

  • (String)


75
76
77
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 75

def documentation_url
  @documentation_url
end

#error_codeString

The particular error code. Safe for programmatic use.

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 26

def error_code
  @error_code
end

#error_code_reasonString

The specific reason for the error code. Currently, reasons are only supported OAuth-based item errors; ‘null` will be returned otherwise. Safe for programmatic use. Possible values: `OAUTH_INVALID_TOKEN`: The user’s OAuth connection to this institution has been invalidated. `OAUTH_CONSENT_EXPIRED`: The user’s access consent for this OAuth connection to this institution has expired. ‘OAUTH_USER_REVOKED`: The user’s OAuth connection to this institution is invalid because the user revoked their connection.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 39

def error_code_reason
  @error_code_reason
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)


44
45
46
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 44

def error_message
  @error_message
end

#error_typePlaidErrorType

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

Returns:



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

def error_type
  @error_type
end

#provided_account_subtypesArray[String]

A list of the account subtypes that were extracted but did not match the requested subtypes via the ‘account_filters` parameter in `/link/token/create`. Currently only populated for `NO_ACCOUNTS` errors from Items with `investments_auth` as an enabled product.

Returns:

  • (Array[String])


93
94
95
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 93

def 
  @provided_account_subtypes
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)


55
56
57
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 55

def request_id
  @request_id
end

#required_account_subtypesArray[String]

A list of the account subtypes that were requested via the ‘account_filters` parameter in `/link/token/create`. Currently only populated for `NO_ACCOUNTS` errors from Items with `investments_auth` as an enabled product.

Returns:

  • (Array[String])


86
87
88
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 86

def 
  @required_account_subtypes
end

#statusInteger

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:

  • (Integer)


70
71
72
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 70

def status
  @status
end

#suggested_actionString

Suggested steps for resolving the error

Returns:

  • (String)


79
80
81
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 79

def suggested_action
  @suggested_action
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 142

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} error_type: #{@error_type.inspect}, error_code: #{@error_code.inspect},"\
  " error_code_reason: #{@error_code_reason.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}, required_account_subtypes:"\
  " #{@required_account_subtypes.inspect}, provided_account_subtypes:"\
  " #{@provided_account_subtypes.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



131
132
133
134
135
136
137
138
139
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 131

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



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/the_plaid_api/exceptions/error_error_exception.rb', line 107

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_code_reason =
    hash.key?('error_code_reason') ? hash['error_code_reason'] : SKIP
  @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
  @required_account_subtypes =
    hash.key?('required_account_subtypes') ? hash['required_account_subtypes'] : SKIP
  @provided_account_subtypes =
    hash.key?('provided_account_subtypes') ? hash['provided_account_subtypes'] : SKIP
end