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

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



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

#codeInteger (readonly)



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

  def hash
    @hash_object
  end

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

#hashHash (readonly)



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

  def hash
    @hash_object
  end

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

#messageString (readonly)



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

  def hash
    @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