1use std::num::ParseIntError;
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum DurationError {
7 #[error("Duration must lie between {range}")]
8 DurationMustLieBetween { range: String },
9
10 #[error("Duration must be specified as a positive integer, immediately followed by days, h, min, s, ms, μs or ns")]
11 InvalidSyntax,
12
13 #[error("Invalid duration value")]
14 InvalidValue {
15 #[from]
16 source: ParseIntError,
17 },
18
19 #[error("Duration would become too large at {duration}, total should be less than 500 years")]
20 IntegerOverflowAt { duration: String },
21
22 #[error("'{sym}' is not supported as a duration symbol")]
23 UnitMatchAndRegexNotInSync { sym: String },
24
25 #[error("Invalid range: should be {minimal} <= {maximal}")]
26 DurationValidationMinMustBeLessOrEqualMax { minimal: String, maximal: String },
27
28 #[error("Invalid range: should be {minimal} <= {default} <= {maximal}")]
29 DurationValidationMustBeOrdered {
30 minimal: String,
31 default: String,
32 maximal: String,
33 },
34
35 #[error("could not find min duration")]
36 DurationValidationMinMustBeSpecified,
37
38 #[error("could not find max duration")]
39 DurationValidationMaxMustBeSpecified,
40
41 #[error("min duration must be 1s or longer")]
42 DurationValidationMinMustBeMoreThanOneSecond,
43
44 #[error("default duration must be 1s or longer")]
45 DurationValidationDefaultMustBeMoreThanOneSecond,
46}