Class: Ably::Realtime::Models::ErrorInfo
- Inherits:
-
Object
- Object
- Ably::Realtime::Models::ErrorInfo
- Includes:
- Modules::Conversions, Shared
- Defined in:
- lib/ably/realtime/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).
-
#json ⇒ Hash
(also: #to_json)
readonly
Access the protocol message Hash object ruby’fied to use symbolized keys.
-
#message ⇒ String
readonly
Additional reason information, where available.
-
#status ⇒ Integer
readonly
HTTP Status Code corresponding to this error, where applicable.
Instance Method Summary collapse
-
#initialize(json_object) ⇒ ErrorInfo
constructor
A new instance of ErrorInfo.
- #to_s ⇒ Object
Methods included from Shared
Constructor Details
#initialize(json_object) ⇒ ErrorInfo
Returns a new instance of ErrorInfo.
18 19 20 21 |
# File 'lib/ably/realtime/models/error_info.rb', line 18 def initialize(json_object) @raw_json_object = json_object @json_object = IdiomaticRubyWrapper(@raw_json_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 37 |
# File 'lib/ably/realtime/models/error_info.rb', line 14 class ErrorInfo include Shared include Ably::Modules::Conversions def initialize(json_object) @raw_json_object = json_object @json_object = IdiomaticRubyWrapper(@raw_json_object.clone.freeze) end %w( message code status ).each do |attribute| define_method attribute do json[attribute.to_sym] end end def json @json_object end alias_method :to_json, :json def to_s "Error: #{message} (code: #{code}, status: #{status})" end end |
#json ⇒ Hash (readonly) Also known as: to_json
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 37 |
# File 'lib/ably/realtime/models/error_info.rb', line 14 class ErrorInfo include Shared include Ably::Modules::Conversions def initialize(json_object) @raw_json_object = json_object @json_object = IdiomaticRubyWrapper(@raw_json_object.clone.freeze) end %w( message code status ).each do |attribute| define_method attribute do json[attribute.to_sym] end end def json @json_object end alias_method :to_json, :json def to_s "Error: #{message} (code: #{code}, 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 37 |
# File 'lib/ably/realtime/models/error_info.rb', line 14 class ErrorInfo include Shared include Ably::Modules::Conversions def initialize(json_object) @raw_json_object = json_object @json_object = IdiomaticRubyWrapper(@raw_json_object.clone.freeze) end %w( message code status ).each do |attribute| define_method attribute do json[attribute.to_sym] end end def json @json_object end alias_method :to_json, :json def to_s "Error: #{message} (code: #{code}, status: #{status})" end end |
#status ⇒ Integer (readonly)
Returns HTTP Status Code corresponding to this error, where applicable.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ably/realtime/models/error_info.rb', line 14 class ErrorInfo include Shared include Ably::Modules::Conversions def initialize(json_object) @raw_json_object = json_object @json_object = IdiomaticRubyWrapper(@raw_json_object.clone.freeze) end %w( message code status ).each do |attribute| define_method attribute do json[attribute.to_sym] end end def json @json_object end alias_method :to_json, :json def to_s "Error: #{message} (code: #{code}, status: #{status})" end end |
Instance Method Details
#to_s ⇒ Object
34 35 36 |
# File 'lib/ably/realtime/models/error_info.rb', line 34 def to_s "Error: #{message} (code: #{code}, status: #{status})" end |