Exception: Ably::Exceptions::BaseAblyException
- Inherits:
-
StandardError
- Object
- StandardError
- Ably::Exceptions::BaseAblyException
- 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/main/protocol/errors.json
Direct Known Subclasses
ChannelInactive, CipherError, ConnectionError, EncoderError, ForbiddenRequest, IncompatibleClientId, InsecureRequest, InvalidCredentials, InvalidRequest, InvalidResponseBody, InvalidState, InvalidStateChange, InvalidTokenRequest, MaxFrameSizeExceeded, MaxMessageSizeExceeded, MessageDeliveryFailed, MessageQueueingDisabled, PageMissing, ProtocolError, PushNotificationsNotSupported, ResourceMissing, ServerError, Standard, TokenExpired, TokenRequestFailed, UnauthorizedRequest, UnsupportedDataType, Models::DeviceDetails, Models::DevicePushDetails, Models::ErrorInfo, Models::PushChannelSubscription
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
Ably specific error code.
-
#message ⇒ String
readonly
Error message from Ably.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#status ⇒ String
readonly
HTTP status code of error.
Instance Method Summary collapse
- #as_json(*args) ⇒ Object
-
#initialize(message, status = nil, code = nil, base_exception = nil, options = {}) ⇒ BaseAblyException
constructor
A new instance of BaseAblyException.
- #to_s ⇒ Object
Constructor Details
#initialize(message, status = nil, code = nil, base_exception = nil, options = {}) ⇒ BaseAblyException
Returns a new instance of BaseAblyException.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 19 def initialize(, status = nil, code = nil, base_exception = nil, = {}) super @base_exception = base_exception @status = status @status ||= base_exception.status if base_exception && base_exception.respond_to?(:status) @status ||= [:fallback_status] @code = code @code ||= base_exception.code if base_exception && base_exception.respond_to?(:code) @code ||= [:fallback_code] @request_id ||= [:request_id] end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns Ably specific error code.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 16 class BaseAblyException < StandardError attr_reader :status, :code, :request_id def initialize(, status = nil, code = nil, base_exception = nil, = {}) super @base_exception = base_exception @status = status @status ||= base_exception.status if base_exception && base_exception.respond_to?(:status) @status ||= [:fallback_status] @code = code @code ||= base_exception.code if base_exception && base_exception.respond_to?(:code) @code ||= [:fallback_code] @request_id ||= [:request_id] end def to_s = [super] if status || code additional_info = [] additional_info << "code: #{code}" if code additional_info << "http status: #{status}" if status additional_info << "base exception: #{@base_exception.class}" if @base_exception additional_info << "request_id: #{request_id}" if request_id << "(#{additional_info.join(', ')})" << "-> see https://help.ably.io/error/#{code} for help" if code end .join(' ') end def as_json(*args) { message: "#{self.class}: #{}", status: @status, code: @code }.delete_if { |key, val| val.nil? } end end |
#message ⇒ String (readonly)
Returns Error message from Ably.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 16 class BaseAblyException < StandardError attr_reader :status, :code, :request_id def initialize(, status = nil, code = nil, base_exception = nil, = {}) super @base_exception = base_exception @status = status @status ||= base_exception.status if base_exception && base_exception.respond_to?(:status) @status ||= [:fallback_status] @code = code @code ||= base_exception.code if base_exception && base_exception.respond_to?(:code) @code ||= [:fallback_code] @request_id ||= [:request_id] end def to_s = [super] if status || code additional_info = [] additional_info << "code: #{code}" if code additional_info << "http status: #{status}" if status additional_info << "base exception: #{@base_exception.class}" if @base_exception additional_info << "request_id: #{request_id}" if request_id << "(#{additional_info.join(', ')})" << "-> see https://help.ably.io/error/#{code} for help" if code end .join(' ') end def as_json(*args) { message: "#{self.class}: #{}", status: @status, code: @code }.delete_if { |key, val| val.nil? } end end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
17 18 19 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 17 def request_id @request_id end |
#status ⇒ String (readonly)
Returns HTTP status code of error.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 16 class BaseAblyException < StandardError attr_reader :status, :code, :request_id def initialize(, status = nil, code = nil, base_exception = nil, = {}) super @base_exception = base_exception @status = status @status ||= base_exception.status if base_exception && base_exception.respond_to?(:status) @status ||= [:fallback_status] @code = code @code ||= base_exception.code if base_exception && base_exception.respond_to?(:code) @code ||= [:fallback_code] @request_id ||= [:request_id] end def to_s = [super] if status || code additional_info = [] additional_info << "code: #{code}" if code additional_info << "http status: #{status}" if status additional_info << "base exception: #{@base_exception.class}" if @base_exception additional_info << "request_id: #{request_id}" if request_id << "(#{additional_info.join(', ')})" << "-> see https://help.ably.io/error/#{code} for help" if code end .join(' ') end def as_json(*args) { message: "#{self.class}: #{}", status: @status, code: @code }.delete_if { |key, val| val.nil? } end end |
Instance Method Details
#as_json(*args) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 46 def as_json(*args) { message: "#{self.class}: #{}", status: @status, code: @code }.delete_if { |key, val| val.nil? } end |
#to_s ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/submodules/ably-ruby/lib/ably/exceptions.rb', line 32 def to_s = [super] if status || code additional_info = [] additional_info << "code: #{code}" if code additional_info << "http status: #{status}" if status additional_info << "base exception: #{@base_exception.class}" if @base_exception additional_info << "request_id: #{request_id}" if request_id << "(#{additional_info.join(', ')})" << "-> see https://help.ably.io/error/#{code} for help" if code end .join(' ') end |