error enum
An enum with one variant per way an operation can fail.
An error enum lists the failures a caller can tell apart and act on, each variant carrying the data that failure needs.
Examples
enum ConfigError { MissingEquals { line: usize }, UnknownKey { line: usize, key: String } }lets a callermatchon which failure happened and read its line number.
See also