module LunaPark::Extensions::Exceptions::Substitutive::InstanceMethods

Attributes

backtrace[W]
origin[RW]

Public Instance Methods

backtrace() click to toggle source
Calls superclass method
# File lib/luna_park/extensions/exceptions/substitutive.rb, line 48
def backtrace
  super || @backtrace
end
cover_up_backtrace() click to toggle source

Cover up trace for current exception

@example bad case

begin
  call_exceptional_lib!
rescue ExceptionalLib::SomeException => e
  send_alert_to_developer
  raise e # => raised `ExceptionalLib::SomeException` with backtrace started
          #      from current line and not contained origin exception backtrace
          #      that can be very painful for debug
end

@example resolve

begin
  call_exceptional_lib!
rescue ExceptionalLib::SomeException => e
  send_alert_to_developer
  raise e.cover_up_backtrace # => raised `ExceptionalLib::SomeException` with original backtrace
                             #       so you can easily find out where exception starts
end
# File lib/luna_park/extensions/exceptions/substitutive.rb, line 72
def cover_up_backtrace
  new = dup
  new.backtrace = backtrace
  new.origin    = self
  new
end