Class: WalmartApIs::ErrorErrorException
- Inherits:
-
APIException
- Object
- CoreLibrary::ApiException
- APIException
- WalmartApIs::ErrorErrorException
- Defined in:
- lib/walmart_ap_is/exceptions/error_error_exception.rb
Overview
Error response returned when the request is unsuccessful.
Instance Attribute Summary collapse
-
#code ⇒ String
An error code that identifies the type of error that occurred.
-
#details ⇒ String
Additional details that can help the caller understand or fix the issue.
-
#message ⇒ String
A message that describes the error condition.
Instance Method Summary collapse
-
#initialize(reason, response) ⇒ ErrorErrorException
constructor
The constructor.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
-
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash.
Constructor Details
#initialize(reason, response) ⇒ ErrorErrorException
The constructor.
27 28 29 30 31 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 27 def initialize(reason, response) super(reason, response) hash = APIHelper.json_deserialize(@response.raw_body) unbox(hash) end |
Instance Attribute Details
#code ⇒ String
An error code that identifies the type of error that occurred.
14 15 16 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 14 def code @code end |
#details ⇒ String
Additional details that can help the caller understand or fix the issue.
22 23 24 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 22 def details @details end |
#message ⇒ String
A message that describes the error condition.
18 19 20 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 18 def @message end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
51 52 53 54 55 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 51 def inspect class_name = self.class.name.split('::').last "<#{class_name} code: #{@code.inspect}, message: #{@message.inspect}, details:"\ " #{@details.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
45 46 47 48 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 45 def to_s class_name = self.class.name.split('::').last "<#{class_name} code: #{@code}, message: #{@message}, details: #{@details}>" end |
#unbox(hash) ⇒ Object
Populates this object by extracting properties from a hash. response body.
36 37 38 39 40 41 42 |
# File 'lib/walmart_ap_is/exceptions/error_error_exception.rb', line 36 def unbox(hash) return nil unless hash @code = hash.key?('code') ? hash['code'] : nil @message = hash.key?('message') ? hash['message'] : nil @details = hash.key?('details') ? hash['details'] : SKIP end |