Exception: Ably::Models::ErrorInfo

Inherits:
Exceptions::BaseAblyException 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

Attributes inherited from Exceptions::BaseAblyException

#request_id

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


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

#attributesHash (readonly)


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

#codeInteger (readonly)


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

#messageString (readonly)


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

Instance Method Details

#to_sObject


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