summaryrefslogtreecommitdiffstats
path: root/src/error/error_kind.rs
blob: 7260e2d6ca1abcd5e0fea7da994880cea1bdcc80 (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
45
46
47
48
49
50
use std::convert::From;
use std::io;

#[derive(Clone, Debug)]
pub enum JoshutoErrorKind {
    // io related
    Io(io::ErrorKind),

    // environment variable not found
    EnvVarNotPresent,

    // parse error
    ParseError,
    ClipboardError,
    TomlDeError(toml::de::Error),

    #[cfg(feature = "recycle_bin")]
    TrashError,

    Glob,

    InvalidParameters,

    UnrecognizedArgument,
    UnrecognizedCommand,
}

impl From<io::ErrorKind> for JoshutoErrorKind {
    fn from(err: io::ErrorKind) -> Self {
        Self::Io(err)
    }
}

impl From<&globset::ErrorKind> for JoshutoErrorKind {
    fn from(_: &globset::ErrorKind) -> Self {
        Self::Glob
    }
}

impl From<std::env::VarError> for JoshutoErrorKind {
    fn from(_: std::env::VarError) -> Self {
        Self::EnvVarNotPresent
    }
}

impl From<toml::de::Error> for JoshutoErrorKind {
    fn from(err: toml::de::Error) -> Self {
        Self::TomlDeError(err)
    }
}