xsd_parser/interpreter/
error.rs

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use thiserror::Error;

use crate::misc::RawByteStr;
use crate::schema::xs::AttributeType;
use crate::schema::{Namespace, NamespacePrefix};
use crate::types::Ident;

/// error raised by the [`Interpreter`](super::Interpreter).
#[derive(Debug, Error)]
pub enum Error {
    /// Type has already been defined.
    ///
    /// Is raised if a new type with an already existing identifier is added
    /// to the [`Types`](crate::types::Types) structure.
    #[error("Type has already been defined: {0}!")]
    TypeAlreadyDefined(Ident),

    /// Expected abstract element.
    ///
    /// Expected the specified element to be abstract because it is referenced
    /// as substitution group.
    #[error("Expected abstract element: {0}!")]
    ExpectedAbstractElement(Ident),

    /// Unknown type.
    ///
    /// Is raised if a type identifier could not been resolved to the actual
    /// type information.
    #[error("Unknown type: {0}!")]
    UnknownType(Ident),

    /// Unknown element.
    ///
    /// Is raised if an element referenced inside the XML schema could not be resolved.
    #[error("Unknown element: {0}!")]
    UnknownElement(Ident),

    /// Unknown attribute.
    ///
    /// Is raised if an attribute referenced inside the XML schema could not be resolved.
    #[error("Unknown attribute: {0}!")]
    UnknownAttribute(String),

    /// Unknown namespace.
    ///
    /// Is raised if the namespace URI could not be resolved.
    #[error("Unknown namespace: {0}!")]
    UnknownNamespace(Namespace),

    /// Unknown namespace prefix.
    ///
    /// Is raised if the namespace prefix could not be resolved.
    #[error("Unknown namespace prefix: {0}!")]
    UnknownNamespacePrefix(NamespacePrefix),

    /// Invalid value.
    ///
    /// Is raised if a value from the XML schema is malformed or invalid.
    #[error("Invalid value for `{0}`!")]
    InvalidValue(&'static str),

    /// Invalid local name.
    ///
    /// Is raised if conversion from a raw local name to a string has failed.
    #[error("Invalid local name `{0}`!")]
    InvalidLocalName(RawByteStr),

    /// Group is missing the `ref` attribute
    ///
    /// Is raised if a group reference in the XML schema is missing the `ref` attribute.
    #[error("Group is missing the `ref` attribute!")]
    GroupMissingRef,

    /// Attribute group is missing the `ref` attribute
    ///
    /// Is raised if a attribute group reference in the XML schema is missing the `ref` attribute.
    #[error("Attribute group is missing the `ref` attribute!")]
    AttributeGroupMissingRef,

    /// Invalid attribute reference.
    ///
    /// The attribute specified in the schema is missing some information.
    #[error("Invalid attribute reference: {0:#?}!")]
    InvalidAttributeReference(Box<AttributeType>),

    /// Internal error.
    ///
    /// IS raised if an internal error occurred. Check the log output for more details.
    #[error("Internal error!")]
    InternalError,

    /// The interpreter expected a group type (like `xs:all`, `xs:choice` or `xs:sequence`).
    #[error("Expected group type!")]
    ExpectedGroupType,
}