Exception: SendLayer::SendLayerError
- Inherits:
-
StandardError
- Object
- StandardError
- SendLayer::SendLayerError
- Defined in:
- lib/sendlayer/exceptions.rb
Overview
Base error for the SendLayer SDK.
Every SendLayer error carries the same attributes, so callers can read them without first checking which subclass they rescued:
status_codeHTTP status of the response, or nil for local errorsresponsedecoded response body, or {} when unavailableerrorsraw SendLayerErrorsentries, each with the API's numericCodeandMessage; empty for local errors and for responses that aren't in that shape
Direct Known Subclasses
SendLayerAPIError, SendLayerAuthenticationError, SendLayerInternalServerError, SendLayerNotFoundError, SendLayerRateLimitError, SendLayerValidationError
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#codes ⇒ Object
Numeric SendLayer error codes carried by this error, for branching: if err.codes.include?(14).
-
#initialize(message = '', status_code = nil, response = nil, errors = nil) ⇒ SendLayerError
constructor
A new instance of SendLayerError.
Constructor Details
#initialize(message = '', status_code = nil, response = nil, errors = nil) ⇒ SendLayerError
Returns a new instance of SendLayerError.
15 16 17 18 19 20 |
# File 'lib/sendlayer/exceptions.rb', line 15 def initialize( = '', status_code = nil, response = nil, errors = nil) @status_code = status_code @response = response.nil? ? {} : response @errors = errors.nil? ? [] : errors super() end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/sendlayer/exceptions.rb', line 13 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/sendlayer/exceptions.rb', line 13 def response @response end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
13 14 15 |
# File 'lib/sendlayer/exceptions.rb', line 13 def status_code @status_code end |
Instance Method Details
#codes ⇒ Object
Numeric SendLayer error codes carried by this error, for branching: if err.codes.include?(14).
See https://developers.sendlayer.com/api-reference/error-codes
26 27 28 |
# File 'lib/sendlayer/exceptions.rb', line 26 def codes @errors.filter_map { |entry| entry['Code'] if entry.is_a?(Hash) && entry.key?('Code') } end |