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
66
67
68
69
//! Error types

use thiserror::Error;

pub type Result<T> = ::std::result::Result<T, Error>;

#[derive(Debug, Error)]
pub enum Error {
    #[cfg(feature = "typed")]
    #[error("{}", _0)]
    TomlSerialize(#[from] ::toml::ser::Error),

    #[cfg(feature = "typed")]
    #[error("{}", _0)]
    TomlDeserialize(#[from] ::toml::de::Error),

    // Errors for tokenizer
    #[error("Parsing the query '{0}' failed")]
    QueryParsingError(String),

    #[error("The query on the TOML is empty")]
    EmptyQueryError,

    #[error("The passed query has an empty identifier")]
    EmptyIdentifier,

    #[error("The passed query tries to access an array but does not specify the index")]
    ArrayAccessWithoutIndex,

    #[error("The passed query tries to access an array but does not specify a valid index")]
    ArrayAccessWithInvalidIndex,

    // Errors for Resolver
    #[error("The identfier '{0}' is not present in the document")]
    IdentifierNotFoundInDocument(String),

    #[error("Got an index query '[{0}]' but have table")]
    NoIndexInTable(usize),

    #[error("Got an identifier query '{0}' but have array")]
    NoIdentifierInArray(String),

    #[error("Got an identifier query '{0}' but have value")]
    QueryingValueAsTable(String),

    #[error("Got an index query '{0}' but have value")]
    QueryingValueAsArray(usize),

    #[error("Cannot delete table '{0:?}' which is not empty")]
    CannotDeleteNonEmptyTable(Option<String>),

    #[error("Cannot delete array '{0:?}' which is not empty")]
    CannotDeleteNonEmptyArray(Option<String>),

    #[error("Cannot access {0} because expected {1}")]
    CannotAccessBecauseTypeMismatch(&'static str, &'static str),

    #[error("Cannot delete in array at {0}, array has length {1}")]
    ArrayIndexOutOfBounds(usize, usize),

    #[error("Cannot access array at {0}, array has length {1}")]
    IndexOutOfBounds(usize, usize),

    #[error("Type Error. Requested {0}, but got {1}")]
    TypeError(&'static str, &'static str),

    #[error("Value at '{0}' not there")]
    NotAvailable(String),
}