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
use crate::named_value::NamedValueError;
use sic_image_engine::errors::SicImageEngineError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum SicParserError {
    #[error("expected named value with signature '{0}', but got no more inputs")]
    ExpectedNamedValue(String),

    #[error("expected value with of type '{0}', but got no more inputs")]
    ExpectedValue(String),

    #[error("unable to parse filter type: {0}")]
    FilterTypeError(SicImageEngineError),

    #[error("unable to parse named value: {0}")]
    NamedValueParsingError(NamedValueError),

    #[error("string value expected an inner value, but none was found")]
    NoInnerString,

    #[error("{0}")]
    OperationError(OperationParamError),

    #[error("unable to parse script: {0}")]
    PestGrammarError(String),

    #[error("parsing failed: operation doesn't exist")]
    UnknownOperationError,

    #[error("unable to parse value '{0}'")]
    ValueParsingError(String),

    #[error("unable to parse value '{0}', error:\n\t{1}")]
    ValueParsingErrorWithInnerError(String, Box<dyn std::error::Error + Send + Sync>),
}

#[derive(Debug, Error)]
pub enum OperationParamError {
    #[error(
        "Unable to parse `set` environment command. Error: expected a single `set` inner element."
    )]
    SetEnvironment,

    #[error("Unable to parse `set` environment command. Error on element: {0}")]
    SetEnvironmentElement(String),

    #[error("Unable to parse operation argument(s): {0}")]
    PestArgError(String),

    #[error(
        "Unable to parse `del` environment command. Error: expected a single `del` inner element."
    )]
    UnsetEnvironment,

    #[error("Unable to parse `del` environment command. Error on element: {0}")]
    UnsetEnvironmentElement(String),
}