Class: SuperPoller::ErrorReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/super_poller/error_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(message_handler, error_handler = nil, &block) ⇒ ErrorReporter

Returns a new instance of ErrorReporter.



2
3
4
5
# File 'lib/super_poller/error_reporter.rb', line 2

def initialize(message_handler, error_handler = nil, &block)
  @message_handler = message_handler
  @error_handler = error_handler || block
end

Instance Method Details

#call(*args) ⇒ Object



7
8
9
10
11
# File 'lib/super_poller/error_reporter.rb', line 7

def call(*args)
  @message_handler.call(*args)
rescue StandardError => e
  @error_handler.call(e, *args)
end