Module: LunaPark::Extensions::Exceptions::Substitutive::InstanceMethods

Defined in:
lib/luna_park/extensions/exceptions/substitutive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backtraceObject



48
49
50
# File 'lib/luna_park/extensions/exceptions/substitutive.rb', line 48

def backtrace
  super || @backtrace
end

#originObject

Returns the value of attribute origin.



45
46
47
# File 'lib/luna_park/extensions/exceptions/substitutive.rb', line 45

def origin
  @origin
end

Instance Method Details

#cover_up_backtraceObject

Cover up trace for current exception

Examples:

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

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


72
73
74
75
76
77
# File 'lib/luna_park/extensions/exceptions/substitutive.rb', line 72

def cover_up_backtrace
  new = dup
  new.backtrace = backtrace
  new.origin    = self
  new
end