Errorable
trait Errorable
Errorable — the trait for values that describe a failure.
Implemented by error types that carry a human-readable message, so a generic handler can display or log any error without knowing its concrete type or its structured fields.
foul report(e: Errorable) -> Void do
IO.printError("error: ${e.message}")
end
Required methods
An implementor writes these.
record ParseError
A parse failure, with everything needed to report it or to carry on from it.
Answered by Integer.parse, Float.parse and Number.parse when the input is not what they expected. Reach for those over to(Integer) exactly when this detail matters: to answers a plain None.
Integer.parse("12x")
# => Error(ParseError { input: "12x", position: 2, value: 12,
# message: "trailing characters after integer",
# rest: "x" })
The position and rest are what make a hand-written scanner possible: the error says exactly where it stopped and what was left.