summaryrefslogtreecommitdiffstats
path: root/src/error.rs
blob: 82eff3d930d8a0dba26091402806bc7ff296ef9e (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
66
67
/// Error types

use thiserror::Error;

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

#[derive(Debug, Error)]
pub enum Error {
    #[error("Serialization error")]
    Serialize(/*#[from] Box<::serde::ser::Error>*/),

    #[error("Deserialization error")]
    Deserialize(/*#[from] Box<::serde::de::Error>*/),

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

    #[error("The query on the document 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 '{}' is not present in the document", _0)]
    IdentifierNotFoundInDocument(String),

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

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

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

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

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

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

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

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

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

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

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