Class: Ably::Models::ErrorInfo

Inherits:
Object
  • Object
show all
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 included from Ably::Modules::ModelCommon

#hash

Instance Method Summary collapse

Methods included from Ably::Modules::ModelCommon

#==, #[], #as_json, #to_json

Methods included from Ably::Modules::MessagePack

#to_msgpack

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

#attributesHash (readonly)

Returns Access the protocol message Hash object ruby’fied to use symbolized keys.

Returns:

  • (Hash)

    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
      attributes[attribute.to_sym]
    end
  end
  alias_method :status, :status_code

  def attributes
    @hash_object
  end

  def to_s
    "Error: #{message} (code: #{code}, http status: #{status})"
  end
end

#codeInteger (readonly)

Returns Ably error code (see ably-common/protocol/errors.json).

Returns:

  • (Integer)

    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
      attributes[attribute.to_sym]
    end
  end
  alias_method :status, :status_code

  def attributes
    @hash_object
  end

  def to_s
    "Error: #{message} (code: #{code}, http status: #{status})"
  end
end

#messageString (readonly)

Returns Additional reason information, where available.

Returns:

  • (String)

    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
      attributes[attribute.to_sym]
    end
  end
  alias_method :status, :status_code

  def attributes
    @hash_object
  end

  def to_s
    "Error: #{message} (code: #{code}, http status: #{status})"
  end
end

Instance Method Details

#to_sObject



33
34
35
# File 'lib/ably/models/error_info.rb', line 33

def to_s
  "Error: #{message} (code: #{code}, http status: #{status})"
end