class Citrus::ParseError
Raised when a parse fails.
Attributes
line[R]
The text of the line in the input where the error occurred.
line_number[R]
The 1-based number of the line in the input where the error occurred.
line_offset[R]
The 0-based offset at which the error occurred on the line on which it occurred in the input.
offset[R]
The 0-based offset at which the error occurred in the input, i.e. the maximum offset in the input that was successfully parsed before the error occurred.
Public Class Methods
new(input)
click to toggle source
The input
given here is an instance of Citrus::Input.
Calls superclass method
# File lib/citrus.rb, line 124 def initialize(input) @offset = input.max_offset @line_offset = input.line_offset(offset) @line_number = input.line_number(offset) @line = input.line(offset) message = "Failed to parse input on line #{line_number}" message << " at offset #{line_offset}\n#{detail}" super(message) end
Public Instance Methods
detail()
click to toggle source
Returns a string that, when printed, gives a visual representation of exactly where the error occurred on its line in the input.
# File lib/citrus.rb, line 153 def detail "#{line}\n#{' ' * line_offset}^" end