Module: Trusty::Errors::ExceptionHandlers

Included in:
Retry, IronIo::QueueProcessor, Rake
Defined in:
lib/trusty/errors/exception_handlers.rb

Instance Method Summary collapse

Instance Method Details

#notify_exception(exception, options = {}) ⇒ Object

include in classes



16
17
18
19
20
21
22
23
# File 'lib/trusty/errors/exception_handlers.rb', line 16

def notify_exception(exception, options = {})
  
  options[:env] ||= respond_to?(:request) ? request.env : respond_to?(:env) ? env : nil
  
  ActiveSupport::Notifications.publish("trusty.errors.notify_exception", exception, options)
  
  raise exception if options[:raise] == true
end

#try_with_data(data, &block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/trusty/errors/exception_handlers.rb', line 7

def try_with_data(data, &block)
  begin
    yield
  rescue => exception
    notify_exception exception, :data => data, :raise => true
  end
end