utc_cron_expr/error/impl.rs
1use super::*;
2
3/// Formats [`CronError`] as a human-readable diagnostic string.
4impl fmt::Display for CronError {
5 /// Writes the diagnostic text to `f`.
6 ///
7 /// # Arguments
8 ///
9 /// - `&mut fmt::Formatter<'_>` - Destination formatter.
10 ///
11 /// # Returns
12 ///
13 /// - `fmt::Result` - Formatting outcome.
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 let msg: &str = match self {
16 Self::InvalidFieldCount => ERR_INVALID_FIELD_COUNT,
17 Self::InvalidFieldSyntax => ERR_INVALID_FIELD_SYNTAX,
18 Self::ValueOutOfRange => ERR_VALUE_OUT_OF_RANGE,
19 Self::InvalidStep => ERR_INVALID_STEP,
20 };
21 f.write_str(msg)
22 }
23}
24
25/// Marks [`CronError`] as a standard error type.
26impl Error for CronError {}