aboutsummaryrefslogtreecommitdiff
path: root/src/errors.rs
blob: 9f570d2e384f62b947cfdecbbc5590021c4ae102 (plain)
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
use std::io;
use std::num::ParseIntError;
use ical::parser;
use toml;

#[derive(Debug)]
pub enum EventError {
    IcalError(parser::errors::Error),
    IntError(ParseIntError),
    StatusError,
    FreqError,
}

impl From<parser::errors::Error> for EventError {
    fn from(err: parser::errors::Error) -> EventError {
        EventError::IcalError(err)
    }
}

impl From<ParseIntError> for EventError {
    fn from(err: ParseIntError) -> EventError {
        EventError::IntError(err)
    }
}

#[derive(Debug)]
pub enum ConfigError {
    IOError(io::Error),
    ParseError(toml::de::Error),
    MissingPath,
}

impl From<io::Error> for ConfigError {
    fn from(err: io::Error) -> ConfigError {
        ConfigError::IOError(err)
    }
}

impl From<toml::de::Error> for ConfigError {
    fn from(err: toml::de::Error) -> ConfigError {
        ConfigError::ParseError(err)
    }
}