Class: Ably::Models::ErrorInfo
- Inherits:
-
Object
- Object
- Ably::Models::ErrorInfo
- Includes:
- Ably::Modules::ModelCommon
- Defined in:
- lib/ably/models/error_info.rb
Overview
An exception type encapsulating error information containing an Ably-specific error code and generic status code.
Instance Attribute Summary collapse
-
#code ⇒ Integer
readonly
Ably error code (see ably-common/protocol/errors.json).
-
#hash ⇒ Hash
readonly
Access the protocol message Hash object ruby’fied to use symbolized keys.
-
#message ⇒ String
readonly
Additional reason information, where available.
Instance Method Summary collapse
-
#initialize(hash_object) ⇒ ErrorInfo
constructor
A new instance of ErrorInfo.
- #to_s ⇒ Object
Methods included from Ably::Modules::ModelCommon
Methods included from Ably::Modules::MessagePack
Constructor Details
#initialize(hash_object) ⇒ ErrorInfo
Returns a new instance of ErrorInfo.
17 18 19 20 |
# File 'lib/ably/models/error_info.rb', line 17 def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end |
Instance Attribute Details
#code ⇒ Integer (readonly)
Returns Ably error code (see ably-common/protocol/errors.json).
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ably/models/error_info.rb', line 14 class ErrorInfo include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code status_code).each do |attribute| define_method attribute do hash[attribute.to_sym] end end alias_method :status, :status_code def hash @hash_object end def to_s "Error: #{} (code: #{code}, http status: #{status})" end end |
#hash ⇒ Hash (readonly)
Returns Access the protocol message Hash object ruby’fied to use symbolized keys.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ably/models/error_info.rb', line 14 class ErrorInfo include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code status_code).each do |attribute| define_method attribute do hash[attribute.to_sym] end end alias_method :status, :status_code def hash @hash_object end def to_s "Error: #{} (code: #{code}, http status: #{status})" end end |
#message ⇒ String (readonly)
Returns Additional reason information, where available.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ably/models/error_info.rb', line 14 class ErrorInfo include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code status_code).each do |attribute| define_method attribute do hash[attribute.to_sym] end end alias_method :status, :status_code def hash @hash_object end def to_s "Error: #{} (code: #{code}, http status: #{status})" end end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/ably/models/error_info.rb', line 33 def to_s "Error: #{} (code: #{code}, http status: #{status})" end |