aboutsummaryrefslogtreecommitdiff
path: root/bin/src/err.rs
blob: 53c32226232acb4c37e8519355da975d961a83ee (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
use std::{io, path::PathBuf};

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

#[derive(Error, Debug)]
pub enum ConfigErr {
    #[error("error parsing glob `{0:?}`: {1}")]
    InvalidGlob(Option<String>, ErrorKind),
    #[error("path error: {0}")]
    InvalidPath(#[from] io::Error),
    #[error("unable to parse `{0}` as line and column")]
    InvalidPosition(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 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),
}