aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: ce56a045971c8f65b7e33ef1f867b171d92b54dd (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
//! 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,
}