2 class ParseException < RuntimeError
3 attr_accessor :source, :parser, :continued_exception
5 def initialize( message, source=nil, parser=nil, exception=nil )
9 @continued_exception = exception
13 # Quote the original exception, if there was one
14 if @continued_exception
15 err = @continued_exception.inspect
17 err << @continued_exception.backtrace.join("\n")
23 # Get the stack trace and error message
26 # Add contextual information
28 err << "\nLine: #{line}\n"
29 err << "Position: #{position}\n"
30 err << "Last 80 unconsumed characters:\n"
31 err << @source.buffer[0..80].gsub(/\n/, ' ')
38 @source.current_line[0] if @source and defined? @source.current_line and
43 @source.current_line[2] if @source and defined? @source.current_line and