Module: AnyCable::ExceptionsHandling

Defined in:
lib/anycable/exceptions_handling.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.add_handler(block) ⇒ Object Also known as: <<



6
7
8
# File 'lib/anycable/exceptions_handling.rb', line 6

def add_handler(block)
  handlers << block
end

.notify(exp) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/anycable/exceptions_handling.rb', line 12

def notify(exp)
  handlers.each do |handler|
    begin
      handler.call(exp)
    rescue StandardError => exp
      AnyCable.logger.error "!!! EXCEPTION HANDLER THREW AN ERROR !!!"
      AnyCable.logger.error exp
      AnyCable.logger.error exp.backtrace.join("\n") unless exp.backtrace.nil?
    end
  end
end