Class: Ably::Realtime::Models::ErrorInfo

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#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
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

#jsonHash (readonly) Also known as: to_json

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
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

#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
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

#statusInteger (readonly)

Returns HTTP Status Code corresponding to this error, where applicable.

Returns:

  • (Integer)

    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_sObject



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

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