|
2 | 2 |
|
3 | 3 | use crate::escape::EscapeError; |
4 | 4 | use crate::events::attributes::AttrError; |
5 | | -use crate::utils::write_byte_string; |
6 | 5 | use std::fmt; |
7 | 6 | use std::io::Error as IoError; |
8 | 7 | use std::str::Utf8Error; |
@@ -46,7 +45,7 @@ pub enum Error { |
46 | 45 | /// Escape error |
47 | 46 | EscapeError(EscapeError), |
48 | 47 | /// Specified namespace prefix is unknown, cannot resolve namespace for it |
49 | | - UnknownPrefix(Vec<u8>), |
| 48 | + UnknownPrefix(String), |
50 | 49 | } |
51 | 50 |
|
52 | 51 | impl From<IoError> for Error { |
@@ -116,11 +115,7 @@ impl fmt::Display for Error { |
116 | 115 | Error::EmptyDocType => write!(f, "DOCTYPE declaration must not be empty"), |
117 | 116 | Error::InvalidAttr(e) => write!(f, "error while parsing attribute: {}", e), |
118 | 117 | Error::EscapeError(e) => write!(f, "{}", e), |
119 | | - Error::UnknownPrefix(prefix) => { |
120 | | - f.write_str("Unknown namespace prefix '")?; |
121 | | - write_byte_string(f, prefix)?; |
122 | | - f.write_str("'") |
123 | | - } |
| 118 | + Error::UnknownPrefix(prefix) => write!(f, "Unknown namespace prefix '{}'", prefix), |
124 | 119 | } |
125 | 120 | } |
126 | 121 | } |
@@ -170,15 +165,15 @@ pub mod serialize { |
170 | 165 | /// Deserializer encounter a start tag with a specified name when it is |
171 | 166 | /// not expecting. This happens when you try to deserialize a primitive |
172 | 167 | /// value (numbers, strings, booleans) from an XML element. |
173 | | - UnexpectedStart(Vec<u8>), |
| 168 | + UnexpectedStart(String), |
174 | 169 | /// Deserializer encounter an end tag with a specified name when it is |
175 | 170 | /// not expecting. Usually that should not be possible, because XML reader |
176 | 171 | /// is not able to produce such stream of events that lead to this error. |
177 | 172 | /// |
178 | 173 | /// If you get this error this likely indicates and error in the `quick_xml`. |
179 | 174 | /// Please open an issue at <https://github.com/tafia/quick-xml>, provide |
180 | 175 | /// your Rust code and XML input. |
181 | | - UnexpectedEnd(Vec<u8>), |
| 176 | + UnexpectedEnd(String), |
182 | 177 | /// The [`Reader`] produced [`Event::Eof`] when it is not expecting, |
183 | 178 | /// for example, after producing [`Event::Start`] but before corresponding |
184 | 179 | /// [`Event::End`]. |
@@ -224,12 +219,12 @@ pub mod serialize { |
224 | 219 | DeError::KeyNotRead => write!(f, "Invalid `Deserialize` implementation: `MapAccess::next_value[_seed]` was called before `MapAccess::next_key[_seed]`"), |
225 | 220 | DeError::UnexpectedStart(e) => { |
226 | 221 | f.write_str("Unexpected `Event::Start(")?; |
227 | | - write_byte_string(f, e)?; |
| 222 | + write_byte_string(f, e.as_bytes())?; |
228 | 223 | f.write_str(")`") |
229 | 224 | } |
230 | 225 | DeError::UnexpectedEnd(e) => { |
231 | 226 | f.write_str("Unexpected `Event::End(")?; |
232 | | - write_byte_string(f, e)?; |
| 227 | + write_byte_string(f, e.as_bytes())?; |
233 | 228 | f.write_str(")`") |
234 | 229 | } |
235 | 230 | DeError::UnexpectedEof => write!(f, "Unexpected `Event::Eof`"), |
|
0 commit comments