Exception: Parse::LiveQuery::SubscriptionError

Inherits:
Error
  • Object
show all
Defined in:
lib/parse/live_query.rb

Overview

Raised when the LiveQuery server rejects a subscribe request. Carries the originating request_id (the client-assigned sequence number used for op/error correlation on the same socket) and the class_name the subscription targeted. Both are present on Subscription#fail!-constructed instances; standalone SubscriptionError.new("...") callers can omit them and the message is preserved verbatim.

Mirrors the structure of Parse::Error::ProtocolError — the error string contains the contextual prefix when the fields are set so rescue SubscriptionError => e; e.message carries enough for a single-line log line without inspecting e further.

Instance Attribute Summary collapse

Attributes inherited from Error

#code

Instance Method Summary collapse

Constructor Details

#initialize(message_or_error, request_id: nil, class_name: nil) ⇒ SubscriptionError

Returns a new instance of SubscriptionError.



79
80
81
82
83
84
85
86
87
88
# File 'lib/parse/live_query.rb', line 79

def initialize(message_or_error, request_id: nil, class_name: nil)
  @request_id = request_id
  @class_name = class_name
  text = message_or_error.respond_to?(:message) ? message_or_error.message : message_or_error.to_s
  prefix_parts = []
  prefix_parts << "request_id=#{request_id}" if request_id
  prefix_parts << "class=#{class_name}" if class_name
  prefixed = prefix_parts.empty? ? text : "#{prefix_parts.join(' ')} #{text}"
  super(prefixed)
end

Instance Attribute Details

#class_nameString? (readonly)

Returns Parse class the subscription was targeting.

Returns:

  • (String, nil)

    Parse class the subscription was targeting



77
78
79
# File 'lib/parse/live_query.rb', line 77

def class_name
  @class_name
end

#request_idInteger? (readonly)

Returns request id of the failed subscribe.

Returns:

  • (Integer, nil)

    request id of the failed subscribe



75
76
77
# File 'lib/parse/live_query.rb', line 75

def request_id
  @request_id
end