rex_app/ui_helper/
outputs.rs

1use std::fmt;
2use thiserror::Error;
3
4pub enum Output {
5    Nothing(Field),
6    Accepted(Field),
7}
8
9impl fmt::Display for Output {
10    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11        match self {
12            Output::Nothing(value) => write!(f, "{value}: Nothing to check"),
13            Output::Accepted(value) => write!(f, "{value}: Accepted"),
14        }
15    }
16}
17
18#[derive(PartialEq, Debug, Error)]
19pub enum Field {
20    #[error("Date")]
21    Date,
22    #[error("Tx Method")]
23    TxMethod,
24    #[error("Amount")]
25    Amount,
26    #[error("Tx Type")]
27    TxType,
28    #[error("Tags")]
29    Tags,
30}
31
32#[derive(Debug, Error)]
33pub enum VerifierError {
34    #[error("Date: Unknown date")]
35    InvalidDate,
36    #[error("Date: Year length not acceptable. Example Date: 2022-05-01")]
37    InvalidYear,
38    #[error("Date: Month length not acceptable. Example Date: 2022-05-01")]
39    InvalidMonth,
40    #[error("Date: Day length not acceptable. Example Date: 2022-05-01")]
41    InvalidDay,
42    #[error("Date: Month must be between 01-12")]
43    MonthTooBig,
44    #[error("Date: Day must be between 01-31")]
45    DayTooBig,
46    #[error("Date: Date not acceptable and possibly non-existing")]
47    NonExistingDate,
48    #[error("Amount: Value must be bigger than zero")]
49    AmountBelowZero,
50    #[error("TX Method: Transaction Method not found")]
51    InvalidTxMethod,
52    #[error("TX Type: Transaction Type not acceptable. Values: Expense/Income/E/I")]
53    InvalidTxType,
54    #[error("{0}: Error acquired while validating input")]
55    ParsingError(Field),
56    #[error("Amount: TX Method cannot be empty. Value of B cannot be determined")]
57    InvalidBValue,
58    #[error("Tags: Non-existing tags cannot be accepted")]
59    NonExistingTag,
60    #[error("Others: Something went wrong while verifying input. Error: {0}")]
61    Others(String),
62}
63
64#[derive(Debug, Error)]
65pub enum SteppingError {
66    #[error("Date: Failed to step due to invalid date format")]
67    InvalidDate,
68    #[error("Tx Method: Failed to step as the tx method does not exists")]
69    InvalidTxMethod,
70    #[error("Amount: Failed to step due to invalid amount format")]
71    InvalidAmount,
72    #[error("Tx Type: Failed to step due to invalid tx type")]
73    InvalidTxType,
74    #[error("Tags: Failed to step as the tag does not exists")]
75    InvalidTags,
76    #[error("Amount: Failed to step value. Value of B cannot be determined")]
77    UnknownBValue,
78    #[error("{0}: Error acquired while validating input")]
79    ParsingError(Field),
80}