paft_core/error.rs
1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq, Eq)]
4/// Domain-oriented errors shared across the paft workspace.
5pub enum PaftError {
6 /// Invalid value provided for an enum parser.
7 #[error("Invalid {enum_name} value: '{value}'")]
8 InvalidEnumValue {
9 /// Enum type name for context (e.g., "Currency").
10 enum_name: &'static str,
11 /// The offending input value.
12 value: String,
13 },
14
15 /// Invalid canonical token produced by normalization helpers.
16 #[error("Invalid canonical token: '{value}' - canonicalized value must be non-empty")]
17 InvalidCanonicalToken {
18 /// The original input that failed to produce a canonical token.
19 value: String,
20 },
21
22 /// `HistoryRequest`: 'period' start must be before end.
23 #[error("HistoryRequest: 'period' start ({start}) must be before end ({end})")]
24 InvalidPeriod {
25 /// The start timestamp that was invalid.
26 start: i64,
27 /// The end timestamp that was invalid.
28 end: i64,
29 },
30
31 /// Invalid period format provided for parsing.
32 #[error(
33 "Invalid period format: '{format}' - expected formats like '2023Q4', '2023', 'FY2023', '2023-12-31', or '12/31/2023'"
34 )]
35 InvalidPeriodFormat {
36 /// The invalid format string that could not be parsed.
37 format: String,
38 },
39}