Class: Plaid::Error
- Defined in:
- lib/plaid/models/error.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
-
#causes ⇒ Array[Object]
In the Assets product, a request can pertain to more than one Item.
-
#display_message ⇒ String
A user-friendly representation of the error code.
-
#documentation_url ⇒ String
The URL of a Plaid documentation page with more information about the error.
-
#error_code ⇒ String
The particular error code.
-
#error_message ⇒ String
A developer-friendly representation of the error code.
-
#error_type ⇒ ErrorType
A broad categorization of the error.
-
#request_id ⇒ String
A unique ID identifying the request, to be used for troubleshooting purposes.
-
#status ⇒ Float
The HTTP status code associated with the error.
-
#suggested_action ⇒ String
Suggested steps for resolving the error.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(error_type:, error_code:, error_message:, display_message:, request_id: SKIP, causes: SKIP, status: SKIP, documentation_url: SKIP, suggested_action: SKIP, additional_properties: nil) ⇒ Error
constructor
A new instance of Error.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(error_type:, error_code:, error_message:, display_message:, request_id: SKIP, causes: SKIP, status: SKIP, documentation_url: SKIP, suggested_action: SKIP, additional_properties: nil) ⇒ Error
Returns a new instance of Error.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/plaid/models/error.rb', line 96 def initialize(error_type:, error_code:, error_message:, display_message:, request_id: SKIP, causes: SKIP, status: SKIP, documentation_url: SKIP, suggested_action: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @error_type = error_type @error_code = error_code @error_message = @display_message = @request_id = request_id unless request_id == SKIP @causes = causes unless causes == SKIP @status = status unless status == SKIP @documentation_url = documentation_url unless documentation_url == SKIP @suggested_action = suggested_action unless suggested_action == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#causes ⇒ Array[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`.
46 47 48 |
# File 'lib/plaid/models/error.rb', line 46 def causes @causes end |
#display_message ⇒ String
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.
33 34 35 |
# File 'lib/plaid/models/error.rb', line 33 def @display_message end |
#documentation_url ⇒ String
The URL of a Plaid documentation page with more information about the error
56 57 58 |
# File 'lib/plaid/models/error.rb', line 56 def documentation_url @documentation_url end |
#error_code ⇒ String
The particular error code. Safe for programmatic use.
22 23 24 |
# File 'lib/plaid/models/error.rb', line 22 def error_code @error_code end |
#error_message ⇒ String
A developer-friendly representation of the error code. This may change over time and is not safe for programmatic use.
27 28 29 |
# File 'lib/plaid/models/error.rb', line 27 def @error_message end |
#error_type ⇒ ErrorType
A broad categorization of the error. Safe for programatic use.
18 19 20 |
# File 'lib/plaid/models/error.rb', line 18 def error_type @error_type end |
#request_id ⇒ String
A unique ID identifying the request, to be used for troubleshooting purposes. This field will be omitted in errors provided by webhooks.
38 39 40 |
# File 'lib/plaid/models/error.rb', line 38 def request_id @request_id end |
#status ⇒ Float
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.
51 52 53 |
# File 'lib/plaid/models/error.rb', line 51 def status @status end |
#suggested_action ⇒ String
Suggested steps for resolving the error
60 61 62 |
# File 'lib/plaid/models/error.rb', line 60 def suggested_action @suggested_action end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/plaid/models/error.rb', line 116 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. error_type = hash.key?('error_type') ? hash['error_type'] : nil error_code = hash.key?('error_code') ? hash['error_code'] : nil = hash.key?('error_message') ? hash['error_message'] : nil = 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 # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. Error.new(error_type: error_type, error_code: error_code, error_message: , display_message: , request_id: request_id, causes: causes, status: status, documentation_url: documentation_url, suggested_action: suggested_action, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/plaid/models/error.rb', line 63 def self.names @_hash = {} if @_hash.nil? @_hash['error_type'] = 'error_type' @_hash['error_code'] = 'error_code' @_hash['error_message'] = 'error_message' @_hash['display_message'] = 'display_message' @_hash['request_id'] = 'request_id' @_hash['causes'] = 'causes' @_hash['status'] = 'status' @_hash['documentation_url'] = 'documentation_url' @_hash['suggested_action'] = 'suggested_action' @_hash end |
.nullables ⇒ Object
An array for nullable fields
89 90 91 92 93 94 |
# File 'lib/plaid/models/error.rb', line 89 def self.nullables %w[ display_message status ] end |
.optionals ⇒ Object
An array for optional fields
78 79 80 81 82 83 84 85 86 |
# File 'lib/plaid/models/error.rb', line 78 def self.optionals %w[ request_id causes status documentation_url suggested_action ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
163 164 165 166 167 168 169 170 |
# File 'lib/plaid/models/error.rb', line 163 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}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
154 155 156 157 158 159 160 |
# File 'lib/plaid/models/error.rb', line 154 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}, additional_properties: #{@additional_properties}>" end |