aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-04-06 15:38:22 -0500
committerPratik Naik <pratiknaik@gmail.com>2015-04-06 15:38:22 -0500
commit8c4c782c78b45d94e97ee9a26a05c44cae7cd428 (patch)
tree225f163cefff1b7a5e04e8e0f36b627223719abe /lib
parent90566fce53a71660c746e23499f8aa134b457335 (diff)
downloadrails-8c4c782c78b45d94e97ee9a26a05c44cae7cd428.tar.gz
rails-8c4c782c78b45d94e97ee9a26a05c44cae7cd428.tar.bz2
rails-8c4c782c78b45d94e97ee9a26a05c44cae7cd428.zip
Catch exceptions when subscribing to a channel and processing a message
Diffstat (limited to 'lib')
-rw-r--r--lib/action_cable/connection/base.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb
index c5b982acf8..ea5d52e99c 100644
--- a/lib/action_cable/connection/base.rb
+++ b/lib/action_cable/connection/base.rb
@@ -105,23 +105,29 @@ module ActionCable
subscription_klass = server.registered_channels.detect { |channel_klass| channel_klass.find_name == id_options[:channel] }
if subscription_klass
- logger.info "Subscribing to channel: #{id_key}"
+ logger.info "[ActionCable] Subscribing to channel: #{id_key}"
@subscriptions[id_key] = subscription_klass.new(self, id_key, id_options)
else
- logger.error "Unable to subscribe to channel: #{id_key}"
+ logger.error "[ActionCable] Subscription class not found (#{data.inspect})"
end
+ rescue Exception => e
+ logger.error "[ActionCable] Could not subscribe to channel (#{data.inspect})"
+ logger.error e.backtrace.join("\n")
end
def process_message(message)
if @subscriptions[message['identifier']]
@subscriptions[message['identifier']].receive_data(ActiveSupport::JSON.decode message['data'])
else
- logger.error "Unable to process message: #{message}"
+ logger.error "[ActionCable] Unable to process message because no subscription found (#{message.inspect})"
end
+ rescue Exception => e
+ logger.error "[ActionCable] Could not process message (#{data.inspect})"
+ logger.error e.backtrace.join("\n")
end
def unsubscribe_channel(data)
- logger.info "Unsubscribing from channel: #{data['identifier']}"
+ logger.info "[ActionCable] Unsubscribing from channel: #{data['identifier']}"
@subscriptions[data['identifier']].unsubscribe
@subscriptions.delete(data['identifier'])
end