aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: dc34eb7cef0f3b975535893de914a7d5ebf52cf2 (plain) (blame)
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
//! Errors for `frippy` crate using `failure`.

use failure::Fail;

pub fn log_error(e: FrippyError) {
    let text = e.causes()
        .skip(1)
        .fold(format!("{}", e), |acc, err| format!("{}: {}", acc, err));
    error!("{}", text);
}

/// The main crate-wide error type.
#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail, Error)]
#[error = "FrippyError"]
pub enum ErrorKind {
    /// Connection error
    #[fail(display = "A connection error occured")]
    Connection,

    /// Thread spawn error
    #[fail(display = "Failed to spawn thread")]
    ThreadSpawn,

    /// A Url error
    #[fail(display = "A Url error has occured")]
    Url,

    /// A Tell error
    #[fail(display = "A Tell error has occured")]
    Tell,

    /// A Factoids error
    #[fail(display = "A Factoids error has occured")]
    Factoids,

    /// A Remind error
    #[fail(display = "A Remind error has occured")]
    Remind,
}