Module: Tracee::Extensions::Exception

Extended by:
ActiveSupport::Concern
Included in:
Exception
Defined in:
lib/tracee/ext/exception.rb

Instance Method Summary collapse

Instance Method Details

#logObject

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