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

Attributes included from Ably::Modules::ModelCommon

#hash

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

Returns a new instance of ErrorInfo.



28
29
30
31
# File 'lib/ably/models/error_info.rb', line 28

def initialize(hash_object)
  @raw_hash_object = hash_object
  @hash_object     = IdiomaticRubyWrapper(hash_object.clone.freeze)
end

Instance Method Details

#attributesObject



94
95
96
# File 'lib/ably/models/error_info.rb', line 94

def attributes
  @hash_object
end

#causeAbly::Models::ErrorInfo

Information pertaining to what caused the error where available.



69
70
71
# File 'lib/ably/models/error_info.rb', line 69

def cause
  attributes[:cause]
end

#codeInteger

Ably error code.

Returns:

  • (Integer)


39
40
41
# File 'lib/ably/models/error_info.rb', line 39

def code
  attributes[:code]
end

#hrefString

This is included for REST responses to provide a URL for additional help on the error code.

Returns:

  • (String)


49
50
51
# File 'lib/ably/models/error_info.rb', line 49

def href
  attributes[:href]
end

#messageString

Additional message information, where available.

Returns:

  • (String)


59
60
61
# File 'lib/ably/models/error_info.rb', line 59

def message
  attributes[:message]
end

#request_idString

If a request fails, the request ID must be included in the ErrorInfo returned to the user.

Returns:

  • (String)


89
90
91
# File 'lib/ably/models/error_info.rb', line 89

def request_id
  attributes[:request_id]
end

#status_codeInteger Also known as: status

HTTP Status Code corresponding to this error, where applicable.

Returns:

  • (Integer)


79
80
81
# File 'lib/ably/models/error_info.rb', line 79

def status_code
  attributes[:status_code]
end

#to_sObject



98
99
100
101
102
# File 'lib/ably/models/error_info.rb', line 98

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} request_id: #{request_id} cause: #{cause})>#{see_msg}"
end