Exception: REXML::ParseException
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- REXML::ParseException
- Defined in:
- lib/rexml/parseexception.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#continued_exception ⇒ Object
Returns the value of attribute continued_exception.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #context ⇒ Object
-
#initialize(message, source = nil, parser = nil, exception = nil) ⇒ ParseException
constructor
A new instance of ParseException.
- #line ⇒ Object
- #position ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(message, source = nil, parser = nil, exception = nil) ⇒ ParseException
Returns a new instance of ParseException.
6 7 8 9 10 11 |
# File 'lib/rexml/parseexception.rb', line 6 def initialize( , source=nil, parser=nil, exception=nil ) super() @source = source @parser = parser @continued_exception = exception end |
Instance Attribute Details
#continued_exception ⇒ Object
Returns the value of attribute continued_exception.
4 5 6 |
# File 'lib/rexml/parseexception.rb', line 4 def continued_exception @continued_exception end |
#parser ⇒ Object
Returns the value of attribute parser.
4 5 6 |
# File 'lib/rexml/parseexception.rb', line 4 def parser @parser end |
#source ⇒ Object
Returns the value of attribute source.
4 5 6 |
# File 'lib/rexml/parseexception.rb', line 4 def source @source end |
Instance Method Details
#context ⇒ Object
49 50 51 |
# File 'lib/rexml/parseexception.rb', line 49 def context @source.current_line end |
#line ⇒ Object
44 45 46 47 |
# File 'lib/rexml/parseexception.rb', line 44 def line @source.current_line[2] if @source and defined? @source.current_line and @source.current_line end |
#position ⇒ Object
39 40 41 42 |
# File 'lib/rexml/parseexception.rb', line 39 def position @source.current_line[0] if @source and defined? @source.current_line and @source.current_line end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rexml/parseexception.rb', line 13 def to_s # Quote the original exception, if there was one if @continued_exception err = @continued_exception.inspect err << "\n" err << @continued_exception.backtrace.join("\n") err << "\n...\n" else err = "" end # Get the stack trace and error message err << super # Add contextual information if @source err << "\nLine: #{line}\n" err << "Position: #{position}\n" err << "Last 80 unconsumed characters:\n" err.force_encoding("ASCII-8BIT") err << @source.buffer[0..80].force_encoding("ASCII-8BIT").gsub(/\n/, ' ') end err end |