1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//use std::fmt;
use thiserror::Error;

use crate::values::PicoValue;

#[derive(Error, Debug)]
pub enum PicoError {
    #[error("Parse failure in [{filename:?}]")]
    ParseFailure { filename: String },

    #[error("Unusable included file [{filename:?}]")]
    UnusableFile { filename: String },

    #[error(transparent)]
    SerDe(#[from] serde_json::Error),

    #[error("Cant compare apples to oranges `{0}`, `{1}` ")]
    IncompatibleComparison(PicoValue, PicoValue),

    #[error("Value `{0}` did not exist")]
    NoSuchValue(String),

    #[error("Read error")]
    ReadError { source: std::io::Error },

    #[error("XXXXX")]
    IOError(#[from] std::io::Error),

    #[error("kkkk")]
    AnyError(#[from] anyhow::Error),

    #[error("Fatal failure")]
    Crash(String),
}

#[derive(Debug, Error)]
pub enum RuleFileError {
    #[error("MyRead Error [{filename:?}]")]
    ReadError {
        source: std::io::Error,
        filename: String,
    },

    #[error("Failed to parse [{filename:?}]")]
    ParseError {
        source: serde_json::Error,
        filename: String,
    },

    #[error("unknown data store error")]
    Unknown(#[from] anyhow::Error),

    #[error("Unsuported [{url:?}]")]
    Unsuported { url: String },
}

/*impl fmt::Display for PicoError {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "error: {:?}", self)
    }
}
*/
//impl Error for PicoError {}