class Chem::ParseException
- Chem::ParseException
- Chem::Error
- Exception
- Reference
- Object
Overview
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
Defined in:
chem.crConstructors
-
.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.
-
.new(message : String)
Creates a new exception without location.
Instance Method Summary
-
#inspect_with_location(io : IO) : Nil
Writes a string representation of the error including the location to io.
-
#inspect_with_location : String
Returns a string representation of the error including the location.
-
#line : String | Nil
Line (if any) where the issue was found.
-
#location : Tuple(Int32, Int32, Int32) | Nil
Error location (if any).
-
#source_file : String | Nil
Path to file (if any) that produced the error.
Constructor Detail
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 Method Detail
Writes a string representation of the error including the location to io.
Returns a string representation of the error including the location.
Error location (if any). It is a triplet containing line number, column number, and cursor size where the issue is located.