Exception: Ably::Models::ErrorInfo
- Inherits:
-
Exceptions::BaseAblyException
- Object
- StandardError
- Exceptions::BaseAblyException
- 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
-
#attributes ⇒ Hash
readonly
Access the protocol message Hash object ruby’fied to use symbolized keys.
-
#code ⇒ Integer
readonly
Ably error code (see ably-common/protocol/errors.json).
-
#message ⇒ String
readonly
Additional reason information, where available.
Attributes included from Ably::Modules::ModelCommon
Attributes inherited from Exceptions::BaseAblyException
Instance Method Summary collapse
-
#initialize(hash_object) ⇒ ErrorInfo
constructor
A new instance of ErrorInfo.
- #to_s ⇒ Object
Methods included from Ably::Modules::ModelCommon
#==, #[], #as_json, included, #to_json
Methods included from Ably::Modules::MessagePack
Methods inherited from Exceptions::BaseAblyException
Constructor Details
#initialize(hash_object) ⇒ ErrorInfo
Returns a new instance of ErrorInfo.
36 37 38 39 |
# File 'lib/ably/models/error_info.rb', line 36 def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end |
Instance Attribute Details
#attributes ⇒ Hash (readonly)
Returns Access the protocol message Hash object ruby’fied to use symbolized keys.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ably/models/error_info.rb', line 33 class ErrorInfo < Ably::Exceptions::BaseAblyException include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code href status_code).each do |attribute| define_method attribute do attributes[attribute.to_sym] end end alias_method :status, :status_code def attributes @hash_object end def to_s error_href = href || (code ? "https://help.ably.io/error/#{code}" : '') see_msg = " -> see #{error_href} for help" unless .to_s.include?(error_href.to_s) "<Error: #{} (code: #{code}, http status: #{status})>#{see_msg}" end end |
#code ⇒ Integer (readonly)
Returns Ably error code (see ably-common/protocol/errors.json).
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ably/models/error_info.rb', line 33 class ErrorInfo < Ably::Exceptions::BaseAblyException include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code href status_code).each do |attribute| define_method attribute do attributes[attribute.to_sym] end end alias_method :status, :status_code def attributes @hash_object end def to_s error_href = href || (code ? "https://help.ably.io/error/#{code}" : '') see_msg = " -> see #{error_href} for help" unless .to_s.include?(error_href.to_s) "<Error: #{} (code: #{code}, http status: #{status})>#{see_msg}" end end |
#message ⇒ String (readonly)
Returns Additional reason information, where available.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ably/models/error_info.rb', line 33 class ErrorInfo < Ably::Exceptions::BaseAblyException include Ably::Modules::ModelCommon def initialize(hash_object) @raw_hash_object = hash_object @hash_object = IdiomaticRubyWrapper(hash_object.clone.freeze) end %w(message code href status_code).each do |attribute| define_method attribute do attributes[attribute.to_sym] end end alias_method :status, :status_code def attributes @hash_object end def to_s error_href = href || (code ? "https://help.ably.io/error/#{code}" : '') see_msg = " -> see #{error_href} for help" unless .to_s.include?(error_href.to_s) "<Error: #{} (code: #{code}, http status: #{status})>#{see_msg}" end end |
Instance Method Details
#to_s ⇒ Object
52 53 54 55 56 |
# File 'lib/ably/models/error_info.rb', line 52 def to_s error_href = href || (code ? "https://help.ably.io/error/#{code}" : '') see_msg = " -> see #{error_href} for help" unless .to_s.include?(error_href.to_s) "<Error: #{} (code: #{code}, http status: #{status})>#{see_msg}" end |