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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Schema error types.
/// Schema errors that occur during schema processing.
#[derive(Debug, Clone, PartialEq)]
pub enum SchemaError {
/// Invalid occurrence value
InvalidOccurs {
/// The invalid value
value: String,
},
/// minOccurs is greater than maxOccurs
MinOccursGreaterThanMaxOccurs {
/// The minOccurs value
min: u32,
/// The maxOccurs value
max: u32,
},
/// Invalid facet value (not a non-negative integer)
InvalidFacetValue {
/// The facet name (e.g., "minLength", "maxLength")
facet: String,
/// The invalid value
value: String,
/// Reason for invalidity
reason: String,
},
/// minLength is greater than maxLength
MinLengthGreaterThanMaxLength {
/// The minLength value
min_length: u64,
/// The maxLength value
max_length: u64,
},
/// fractionDigits is greater than totalDigits
FractionDigitsGreaterThanTotalDigits {
/// The fractionDigits value
fraction_digits: u64,
/// The totalDigits value
total_digits: u64,
},
/// Schema not found
SchemaNotFound {
/// The schema URI
uri: String,
},
/// Invalid base URI
InvalidBaseUri {
/// The invalid URI
uri: String,
/// Error message
message: String,
},
/// Failed to resolve URL
UrlResolutionFailed {
/// The relative URL
relative: String,
/// The base URL
base: String,
/// Error message
message: String,
},
/// Circular dependency detected in schema imports
CircularDependency {
/// The URI that caused the circular dependency
uri: String,
},
}
impl std::fmt::Display for SchemaError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SchemaError::InvalidOccurs { value } => {
write!(f, "invalid occurs value: {}", value)
}
SchemaError::MinOccursGreaterThanMaxOccurs { min, max } => {
write!(
f,
"minOccurs ({}) cannot be greater than maxOccurs ({})",
min, max
)
}
SchemaError::InvalidFacetValue {
facet,
value,
reason,
} => {
write!(f, "invalid {} value '{}': {}", facet, value, reason)
}
SchemaError::MinLengthGreaterThanMaxLength {
min_length,
max_length,
} => {
write!(
f,
"minLength ({}) cannot be greater than maxLength ({})",
min_length, max_length
)
}
SchemaError::FractionDigitsGreaterThanTotalDigits {
fraction_digits,
total_digits,
} => {
write!(
f,
"fractionDigits ({}) cannot be greater than totalDigits ({})",
fraction_digits, total_digits
)
}
SchemaError::SchemaNotFound { uri } => {
write!(f, "schema not found: {}", uri)
}
SchemaError::InvalidBaseUri { uri, message } => {
write!(f, "invalid base URI '{}': {}", uri, message)
}
SchemaError::UrlResolutionFailed {
relative,
base,
message,
} => {
write!(
f,
"failed to resolve '{}' against '{}': {}",
relative, base, message
)
}
SchemaError::CircularDependency { uri } => {
write!(f, "circular dependency in schema imports: {}", uri)
}
}
}
}
impl std::error::Error for SchemaError {}