Exception: Sequence::APIError
- Defined in:
- lib/sequence/errors.rb
Overview
APIError describes errors that are codified by the Sequence API. They have an error code, a message, and an optional detail field that provides additional context for the error.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#chain_message ⇒ Object
Returns the value of attribute chain_message.
-
#data ⇒ Object
Returns the value of attribute data.
-
#detail ⇒ Object
Returns the value of attribute detail.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#response ⇒ Object
Returns the value of attribute response.
-
#retriable ⇒ Object
Returns the value of attribute retriable.
-
#seq_code ⇒ Object
Returns the value of attribute seq_code.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(body, response) ⇒ APIError
constructor
A new instance of APIError.
- #retriable? ⇒ Boolean
Constructor Details
#initialize(body, response) ⇒ APIError
Returns a new instance of APIError.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sequence/errors.rb', line 49 def initialize(body, response) self. = body['message'] self.detail = body['detail'] self.retriable = body['retriable'] self.seq_code = body['seq_code'] self.temporary = body['retriable'] self.response = response self.request_id = response['Chain-Request-ID'] if response super( self.class.( seq_code, , detail, request_id, ) ) end |
Instance Attribute Details
#chain_message ⇒ Object
Returns the value of attribute chain_message.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def @chain_message end |
#data ⇒ Object
Returns the value of attribute data.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def data @data end |
#detail ⇒ Object
Returns the value of attribute detail.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def detail @detail end |
#request_id ⇒ Object
Returns the value of attribute request_id.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def request_id @request_id end |
#response ⇒ Object
Returns the value of attribute response.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def response @response end |
#retriable ⇒ Object
Returns the value of attribute retriable.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def retriable @retriable end |
#seq_code ⇒ Object
Returns the value of attribute seq_code.
38 39 40 |
# File 'lib/sequence/errors.rb', line 38 def seq_code @seq_code end |
Class Method Details
.format_error_message(seq_code, message, detail, request_id) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sequence/errors.rb', line 74 def self.(seq_code, , detail, request_id) tokens = [] if seq_code.is_a?(String) && !seq_code.empty? tokens << "Code: #{seq_code}" end tokens << "Message: #{}" if detail.is_a?(String) && !detail.empty? tokens << "Detail: #{detail}" end tokens << "Request-ID: #{request_id}" tokens.join(' ') end |
Instance Method Details
#retriable? ⇒ Boolean
69 70 71 |
# File 'lib/sequence/errors.rb', line 69 def retriable? retriable end |