|
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; |
@@ -38,7 +37,7 @@ pub enum Error { |
38 | 37 | /// Escape error |
39 | 38 | EscapeError(EscapeError), |
40 | 39 | /// Specified namespace prefix is unknown, cannot resolve namespace for it |
41 | | - UnknownPrefix(Vec<u8>), |
| 40 | + UnknownPrefix(String), |
42 | 41 | } |
43 | 42 |
|
44 | 43 | impl From<IoError> for Error { |
@@ -107,11 +106,7 @@ impl fmt::Display for Error { |
107 | 106 | ), |
108 | 107 | Error::InvalidAttr(e) => write!(f, "error while parsing attribute: {}", e), |
109 | 108 | Error::EscapeError(e) => write!(f, "{}", e), |
110 | | - Error::UnknownPrefix(prefix) => { |
111 | | - f.write_str("Unknown namespace prefix '")?; |
112 | | - write_byte_string(f, prefix)?; |
113 | | - f.write_str("'") |
114 | | - } |
| 109 | + Error::UnknownPrefix(prefix) => write!(f, "Unknown namespace prefix '{}'", prefix), |
115 | 110 | } |
116 | 111 | } |
117 | 112 | } |
@@ -161,15 +156,15 @@ pub mod serialize { |
161 | 156 | /// Deserializer encounter a start tag with a specified name when it is |
162 | 157 | /// not expecting. This happens when you try to deserialize a primitive |
163 | 158 | /// value (numbers, strings, booleans) from an XML element. |
164 | | - UnexpectedStart(Vec<u8>), |
| 159 | + UnexpectedStart(String), |
165 | 160 | /// Deserializer encounter an end tag with a specified name when it is |
166 | 161 | /// not expecting. Usually that should not be possible, because XML reader |
167 | 162 | /// is not able to produce such stream of events that lead to this error. |
168 | 163 | /// |
169 | 164 | /// If you get this error this likely indicates and error in the `quick_xml`. |
170 | 165 | /// Please open an issue at <https://github.com/tafia/quick-xml>, provide |
171 | 166 | /// your Rust code and XML input. |
172 | | - UnexpectedEnd(Vec<u8>), |
| 167 | + UnexpectedEnd(String), |
173 | 168 | /// The [`Reader`] produced [`Event::Eof`] when it is not expecting, |
174 | 169 | /// for example, after producing [`Event::Start`] but before corresponding |
175 | 170 | /// [`Event::End`]. |
@@ -215,12 +210,12 @@ pub mod serialize { |
215 | 210 | DeError::KeyNotRead => write!(f, "Invalid `Deserialize` implementation: `MapAccess::next_value[_seed]` was called before `MapAccess::next_key[_seed]`"), |
216 | 211 | DeError::UnexpectedStart(e) => { |
217 | 212 | f.write_str("Unexpected `Event::Start(")?; |
218 | | - write_byte_string(f, e)?; |
| 213 | + write_byte_string(f, e.as_bytes())?; |
219 | 214 | f.write_str(")`") |
220 | 215 | } |
221 | 216 | DeError::UnexpectedEnd(e) => { |
222 | 217 | f.write_str("Unexpected `Event::End(")?; |
223 | | - write_byte_string(f, e)?; |
| 218 | + write_byte_string(f, e.as_bytes())?; |
224 | 219 | f.write_str(")`") |
225 | 220 | } |
226 | 221 | DeError::UnexpectedEof => write!(f, "Unexpected `Event::Eof`"), |
|
0 commit comments