Skip to content

Commit 8f4ec5f

Browse files
committed
show full exception info when failed to evaluate expression
1 parent 220d78b commit 8f4ec5f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/ruby-debug/xml_printer.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@
44
module Debugger
55

66
class XmlPrinter # :nodoc:
7+
class ExceptionProxy
8+
instance_methods.each { |m| undef_method m unless m =~ /(^__|^send$|^object_id$|^instance_variables$|^instance_eval$)/ }
9+
10+
def initialize(exception)
11+
@exception = exception
12+
@message = exception.message
13+
@backtrace = cleanup_backtrace(exception.backtrace)
14+
end
15+
16+
private
17+
def method_missing(called, *args, &block)
18+
@exception.__send__(called, *args, &block)
19+
end
20+
21+
def cleanup_backtrace(backtrace)
22+
cleared = []
23+
return cleared unless backtrace
24+
backtrace.each do |line|
25+
if line.index(File.expand_path(File.dirname(__FILE__))) == 0
26+
break
27+
end
28+
cleared << line
29+
end
30+
cleared
31+
end
32+
end
33+
734
attr_accessor :interface
835

936
def initialize(interface)
@@ -229,6 +256,10 @@ def print_at_line(context, file, line)
229256
end
230257

231258
def print_exception(exception, binding)
259+
print_variables(%w(error), 'exception') do |var|
260+
ExceptionProxy.new(exception)
261+
end
262+
rescue
232263
print "<processingException type=\"%s\" message=\"%s\"/>",
233264
exception.class, CGI.escapeHTML(exception.to_s)
234265
end

0 commit comments

Comments
 (0)