Chem::ParseException
Inherits Chem::Error / Exception / Reference / Object
Exception thrown upon parsing issues. Primarly used by PullParser.
It can hold the location of the issue found in a text document. Call
#inspect_with_location to print a human-friendly error showing
such information.
ex = ParseException.new(
message: "Invalid letters",
path: "path/to/file",
line: "abc def 123456 ABC DEF",
location: {247, 8, 6}
)
puts ex.inspect_with_location
Prints out:
Found a parsing issue in path/to/file:
247 | abc def 123456 ABC DEF
^^^^^^
Error: Invalid letters
Constructors
new(message : String, source_file : String | Nil, line : String, location : Tuple(Int32, Int32, Int32))
Creates a new exception with location, which is a triplet containing line number, column number (starting at zero), and cursor size. The latter may be zero to represent the beginning (column number = 0) or end of line.
Instance methods
inspect_with_location(io : IO) : Nil
Writes a string representation of the error including the location to io.
location
Error location (if any). It is a triplet containing line number, column number, and cursor size where the issue is located.