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

#[derive(Debug)]
pub enum EventError {
    IcalError(ParserError),
    IntError(ParseIntError),
    StatusError,
    FreqError,
    BydayError,
}

impl From<ParserError> for EventError {
    fn from(err: ParserError) -> 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)
    }
}