Module: Tracee::Extensions::Exception
- Defined in:
- lib/tracee/ext/exception.rb
Class Method Summary collapse
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
Class Method Details
.prepended(exc_class) ⇒ Object
5 6 7 |
# File 'lib/tracee/ext/exception.rb', line 5 def self.prepended(exc_class) exc_class.send :class_attribute, :trace_decorator end |
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
60 61 62 63 64 65 |
# File 'lib/tracee/ext/exception.rb', line 60 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
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tracee/ext/exception.rb', line 27 def set_backtrace(trace) if decorator = self.class.trace_decorator if trace.is_a? Thread::Backtrace return trace else trace = decorator.(trace) end end super(trace) end |