Enumerated Errors
Enum, where each variant describes a particular failure mode.
Variants can contain extra info on what went wrong:
enum ParseValueError {
FileDoesNotExistError(PathBuf),
MalformedInputError { line: u64, col: u64 },
}
Even better, using an other error as a source:
enum ParseValueError {
IoError(std::io::Error),
MalformedInputError { line: u64, col: u64 },
}
No trick, just leverage the type system!