Exception: Ably::Models::ErrorInfo

Inherits:
Exceptions::BaseAblyException show all
Includes:
Ably::Modules::ModelCommon
Defined in:
lib/submodules/ably-ruby/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, included, #to_json

Methods included from Ably::Modules::MessagePack

#to_msgpack

Methods inherited from Exceptions::BaseAblyException

#as_json

Constructor Details

#initialize(hash_object) ⇒ ErrorInfo

Returns a new instance of ErrorInfo.



40
41
42
43
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 40

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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 37

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 request_id cause).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 message.to_s.include?(error_href.to_s)
    "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
  end
end

#causeInteger (readonly)

Returns HTTP Status Code corresponding to this error, where applicable (#TI1).

Returns:

  • (Integer)

    HTTP Status Code corresponding to this error, where applicable (#TI1)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 37

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 request_id cause).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 message.to_s.include?(error_href.to_s)
    "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
  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)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 37

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 request_id cause).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 message.to_s.include?(error_href.to_s)
    "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
  end
end

#messageString (readonly)

Returns Additional reason information, where available.

Returns:

  • (String)

    Additional reason information, where available



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 37

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 request_id cause).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 message.to_s.include?(error_href.to_s)
    "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
  end
end

#request_idInteger (readonly)

Returns HTTP RequestId corresponding to this error, where applicable (#RSC7c).

Returns:

  • (Integer)

    HTTP RequestId corresponding to this error, where applicable (#RSC7c)



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 37

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 request_id cause).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 message.to_s.include?(error_href.to_s)
    "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
  end
end

Instance Method Details

#to_sObject



56
57
58
59
60
# File 'lib/submodules/ably-ruby/lib/ably/models/error_info.rb', line 56

def to_s
  error_href = href || (code ? "https://help.ably.io/error/#{code}" : '')
  see_msg = " -> see #{error_href} for help" unless message.to_s.include?(error_href.to_s)
  "<Error: #{message} (code: #{code}, http status: #{status} request_id: #{request_id} cause: #{cause})>#{see_msg}"
end