Module: Tracee::Extensions::Exception
Instance Method Summary collapse
-
#log ⇒ Object
Use case: We have some method that we don’t want to crash application in production but want to have this crash potential been logged.
- #set_backtrace(trace) ⇒ Object
- #set_backtrace_with_decorate(trace) ⇒ Object
Instance Method Details
#log ⇒ Object
Use case: We have some method that we don’t want to crash application in production but want to have this crash potential been logged
def unsured_method
... some crashable calls ...
rescue PotentialException
$!.log
end
59 60 61 62 63 64 |
# File 'lib/tracee/ext/exception.rb', line 59 def log Rails.logger.error [ "The exception has been handled: #{self.class} — #{message.force_encoding('UTF-8')}:", *Rails.backtrace_cleaner.clean(backtrace) ]*"\n" end |
#set_backtrace(trace) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/tracee/ext/exception.rb', line 41 def set_backtrace(trace) if decorator = self.class.trace_decorator trace = decorator.(trace) end set_backtrace_without_decorate(trace) end |
#set_backtrace_with_decorate(trace) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tracee/ext/exception.rb', line 28 def set_backtrace_with_decorate(trace) if decorator = self.class.trace_decorator if trace.is_a? Thread::Backtrace return trace else trace = decorator.(trace) end end set_backtrace_without_decorate(trace) end |