Module: CoreEx::Exception

Included in:
Exception
Defined in:
lib/core_ex/exception.rb

Instance Method Summary collapse

Instance Method Details

#long_ppObject

FIXME: write a ruby_pp which print exception backtrace exactly as ruby does

by cuting long and repetitive backtrace.


13
14
15
16
17
18
# File 'lib/core_ex/exception.rb', line 13

def long_pp
  str = short_pp + "\n"
  backtrace[1..-1].each { |x| str += "  from #{x}\n" } if backtrace
  str.chomp!
  str
end

#short_ppObject



20
21
22
23
24
25
26
# File 'lib/core_ex/exception.rb', line 20

def short_pp
  if backtrace.nil?
    tiny_pp
  else
    "#{backtrace[0]}: #{tiny_pp}"
  end
end

#tiny_ppObject



28
29
30
31
# File 'lib/core_ex/exception.rb', line 28

def tiny_pp
  exc_name = inspect.sub(/^#<(\w+):.+$/, '\1')
  "#{self} (#{exc_name})"
end