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
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub enum ReamError {
    ScanError(ScanErrorType),
    ParseError(ParseErrorType),
    TypeError(TypeErrorType),
    ReferenceError(ReferenceErrorType),
    SchemaError(SchemaErrorType),
    DuplicateKeys, // TODO: better error classification
    Placeholder,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum SchemaErrorType {
    IncorrectParentClass,
    IncorrectKeys,
    IncorrectClass,
    IncorrectSchema, // TODO: need to be more specific
}

#[derive(Debug, Serialize, Deserialize)]
pub enum ReferenceErrorType {
    ReferenceNotFound,
    InvalidReference,
    EntryClassNotFound,
    VariableKeyNotFound,
    IncompatibleTypes,
    DuplicateKeys,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum TypeErrorType {
    UnknownType,
    InvalidNumber,
    InvalidBoolean,
    HeterogeneousList,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum ParseErrorType {
    MissingHeaderLevel,
    MissingIdentifier,
    MissingVariable,
    MissingSubentry,
    MissingValue,
    MissingToken,
    MissingColon,
    WrongHeaderLevel,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum ScanErrorType {
    InvalidToken,
    // ToFewSpaces,
    MissingValue,
    MissingKey,
    MissingClass,
    MissingEOL,
    MissingColon,
    InvalidType,
    WrongHeaderLevel,
}