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)
The input given here is an instance of Citrus::Input.
[show source]
# File lib/citrus.rb, line 125 125: def initialize(input) 126: @offset = input.max_offset 127: @line_offset = input.line_offset(offset) 128: @line_number = input.line_number(offset) 129: @line = input.line(offset) 130: 131: message = "Failed to parse input on line #{line_number}" 132: message << " at offset #{line_offset}\n#{detail}" 133: 134: super(message) 135: end
Public instance methods
detail
()
Returns a string that, when printed, gives a visual representation of exactly where the error occurred on its line in the input.
[show source]
# File lib/citrus.rb, line 154 154: def detail 155: "#{line}\n#{' ' * line_offset}^" 156: end