paft_core/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq, Eq)]
4/// Errors shared across the paft workspace (request validation, parsing, etc.).
5pub enum PaftError {
6    /// Search query must not be empty.
7    #[error("Search query must not be empty")]
8    EmptySearchQuery,
9
10    /// Search limit must be greater than 0.
11    #[error("Search limit must be greater than 0, but was {0}")]
12    InvalidSearchLimit(usize),
13
14    /// `HistoryRequest`: 'range' and 'period' are mutually exclusive.
15    #[error("HistoryRequest: 'range' and 'period' are mutually exclusive")]
16    ExclusiveRangeAndPeriod,
17
18    /// `HistoryRequest`: 'period' start must be before end.
19    #[error("HistoryRequest: 'period' start ({start}) must be before end ({end})")]
20    InvalidPeriod {
21        /// The start timestamp that was invalid.
22        start: i64,
23        /// The end timestamp that was invalid.
24        end: i64,
25    },
26
27    /// Invalid period format provided for parsing.
28    #[error(
29        "Invalid period format: '{format}' - expected formats like '2023Q4', '2023', 'FY2023', '2023-12-31', or '12/31/2023'"
30    )]
31    InvalidPeriodFormat {
32        /// The invalid format string that could not be parsed.
33        format: String,
34    },
35}