@@ -9,6 +9,16 @@ use std::str::Utf8Error;
9
9
use std:: string:: FromUtf8Error ;
10
10
use std:: sync:: Arc ;
11
11
12
+ #[ derive( Clone , Debug ) ]
13
+ pub struct ReservedNamespacePrefixError {
14
+ pub prefix : String ,
15
+ }
16
+
17
+ #[ derive( Clone , Debug ) ]
18
+ pub struct ReservedNamespaceNameError {
19
+ pub name : String ,
20
+ }
21
+
12
22
/// The error type used by this crate.
13
23
#[ derive( Clone , Debug ) ]
14
24
pub enum Error {
@@ -45,6 +55,10 @@ pub enum Error {
45
55
InvalidAttr ( AttrError ) ,
46
56
/// Escape error
47
57
EscapeError ( EscapeError ) ,
58
+ /// Error for when a reserved namespace is explicity set incorrectly
59
+ ReservedNamespacePrefixError ( ReservedNamespacePrefixError ) ,
60
+ /// Error for when a reserved namespace name is used incorrectly
61
+ ReservedNamespaceNameError ( ReservedNamespaceNameError ) ,
48
62
/// Specified namespace prefix is unknown, cannot resolve namespace for it
49
63
UnknownPrefix ( Vec < u8 > ) ,
50
64
}
@@ -120,7 +134,13 @@ impl fmt::Display for Error {
120
134
f. write_str ( "Unknown namespace prefix '" ) ?;
121
135
write_byte_string ( f, prefix) ?;
122
136
f. write_str ( "'" )
123
- }
137
+ } ,
138
+ Error :: ReservedNamespacePrefixError ( e) => write ! (
139
+ f, "The namespace prefix `{}` is invalid." , e. prefix
140
+ ) ,
141
+ Error :: ReservedNamespaceNameError ( e) => write ! (
142
+ f, "The namespace name `{}` is invalid." , e. name
143
+ ) ,
124
144
}
125
145
}
126
146
}
0 commit comments