Sha256: 5a8d934c4bf301d12eddf16425bb8d28541c77feed9484a9a565ce176d3d6662

Contents?: true

Size: 1.13 KB

Versions: 11

Compression:

Stored size: 1.13 KB

Contents

module Ably::Models
  # An exception type encapsulating error information containing
  # an Ably-specific error code and generic status code.
  #
  # @!attribute [r] message
  #   @return [String] Additional reason information, where available
  # @!attribute [r] code
  #   @return [Integer] Ably error code (see ably-common/protocol/errors.json)
  # @!attribute [r] status
  #   @return [Integer] HTTP Status Code corresponding to this error, where applicable
  # @!attribute [r] attributes
  #   @return [Hash] Access the protocol message Hash object ruby'fied to use symbolized keys
  #
  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 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: #{message} (code: #{code}, http status: #{status})"
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ably-1.0.7 lib/ably/models/error_info.rb
ably-rest-1.0.6 lib/submodules/ably-ruby/lib/ably/models/error_info.rb
ably-1.0.6 lib/ably/models/error_info.rb
ably-rest-1.0.5 lib/submodules/ably-ruby/lib/ably/models/error_info.rb
ably-1.0.5 lib/ably/models/error_info.rb
ably-1.0.4 lib/ably/models/error_info.rb
ably-1.0.3 lib/ably/models/error_info.rb
ably-1.0.2 lib/ably/models/error_info.rb
ably-1.0.1 lib/ably/models/error_info.rb
ably-rest-1.0.0 lib/submodules/ably-ruby/lib/ably/models/error_info.rb
ably-1.0.0 lib/ably/models/error_info.rb