Module: Jets::ExceptionReporting::ClassMethods

Defined in:
lib/jets/exception_reporting.rb

Instance Method Summary collapse

Instance Method Details

#decorate_with_exception_reported(exception) ⇒ Object

We decorate the exception with a with_exception_reported? method so we can use it the MainProcessor rescue Exception handling to not double report the exception and only reraise.

If we have properly rescue all exceptions then this would not be needed. However, we’re being paranoid also by rescuing Exception in the MainProcessor.

Also, in general, it’s hard to follow Exception bubbling logic. This approach allows us to not have to worry about bubbling and call with_exception_reporting indiscriminately.



25
26
27
28
29
# File 'lib/jets/exception_reporting.rb', line 25

def decorate_with_exception_reported(exception)
  unless exception.respond_to?(:with_exception_reported?)
    exception.define_singleton_method(:with_exception_reported?) { true }
  end
end

#with_exception_reportingObject



7
8
9
10
11
12
13
# File 'lib/jets/exception_reporting.rb', line 7

def with_exception_reporting
  yield
rescue => exception
  Jets.report_exception(exception)
  decorate_with_exception_reported(exception)
  raise
end