aboutsummaryrefslogtreecommitdiff
path: root/bin/src/err.rs
blob: f44d27b69e5b44d7e3953347cf65ff1863c42ec3 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use std::io;

// use globset::ErrorKind;
// use rnix::parser::ParseError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ConfigErr {
    #[error("error parsing ignore list `{0}`")]
    InvalidGlob(#[from] ignore::Error),
    #[error("path error: {0}")]
    InvalidPath(#[from] io::Error),
    #[error("unable to parse `{0}` as line and column")]
    InvalidPosition(String),
    #[error("unable to parse `{0}` as warning code")]
    InvalidWarningCode(String),
    #[error("unable to parse config file, error at: `{0}`")]
    ConfFileParse(String),
}

// #[derive(Error, Debug)]
// pub enum LintErr {
//     #[error("[{0}] syntax error: {1}")]
//     Parse(PathBuf, ParseError),
// }

#[derive(Error, Debug)]
pub enum FixErr {
    // #[error("[{0}] syntax error: {1}")]
    // Parse(PathBuf, ParseError),
    #[error("path error: {0}")]
    InvalidPath(#[from] io::Error),
}

#[derive(Error, Debug)]
pub enum SingleFixErr {
    #[error("path error: {0}")]
    InvalidPath(#[from] io::Error),
    #[error("position out of bounds: line {0}, col {1}")]
    OutOfBounds(usize, usize),
    #[error("{0} is too large")]
    Conversion(usize),
    #[error("nothing to fix")]
    NoOp,
}

#[derive(Error, Debug)]
pub enum ExplainErr {
    #[error("lint with code `{0}` not found")]
    LintNotFound(u32),
}

#[derive(Error, Debug)]
pub enum StatixErr {
    // #[error("linter error: {0}")]
    // Lint(#[from] LintErr),
    #[error("fixer error: {0}")]
    Fix(#[from] FixErr),
    #[error("single fix error: {0}")]
    Single(#[from] SingleFixErr),
    #[error("config error: {0}")]
    Config(#[from] ConfigErr),
    #[error("explain error: {0}")]
    Explain(#[from] ExplainErr),
}