Exception: Ably::Exceptions::BaseAblyException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/submodules/ably-ruby/lib/ably/exceptions.rb

Overview

Base Ably exception class that contains status and code values used by Ably Refer to github.com/ably/ably-common/blob/master/protocol/errors.json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status = nil, code = nil) ⇒ BaseAblyException

Returns a new instance of BaseAblyException.



14
15
16
17
18
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 14

def initialize(message, status = nil, code = nil)
  super message
  @status = status
  @code = code
end

Instance Attribute Details

#codeString (readonly)

Returns Ably specific error code.

Returns:

  • (String)

    Ably specific error code



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 12

class BaseAblyException < StandardError
  attr_reader :status, :code
  def initialize(message, status = nil, code = nil)
    super message
    @status = status
    @code = code
  end

  def to_s
    message = [super]
    if status || code
      additional_info = []
      additional_info << "code: #{code}" if code
      additional_info << "http status: #{status}" if status
      message << "(#{additional_info.join(', ')})"
    end
    message.join(' ')
  end
end

#messageString (readonly)

Returns Error message from Ably.

Returns:

  • (String)

    Error message from Ably



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 12

class BaseAblyException < StandardError
  attr_reader :status, :code
  def initialize(message, status = nil, code = nil)
    super message
    @status = status
    @code = code
  end

  def to_s
    message = [super]
    if status || code
      additional_info = []
      additional_info << "code: #{code}" if code
      additional_info << "http status: #{status}" if status
      message << "(#{additional_info.join(', ')})"
    end
    message.join(' ')
  end
end

#statusString (readonly)

Returns HTTP status code of error.

Returns:

  • (String)

    HTTP status code of error



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 12

class BaseAblyException < StandardError
  attr_reader :status, :code
  def initialize(message, status = nil, code = nil)
    super message
    @status = status
    @code = code
  end

  def to_s
    message = [super]
    if status || code
      additional_info = []
      additional_info << "code: #{code}" if code
      additional_info << "http status: #{status}" if status
      message << "(#{additional_info.join(', ')})"
    end
    message.join(' ')
  end
end

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 20

def to_s
  message = [super]
  if status || code
    additional_info = []
    additional_info << "code: #{code}" if code
    additional_info << "http status: #{status}" if status
    message << "(#{additional_info.join(', ')})"
  end
  message.join(' ')
end