Open
Description
This can be useful for code that uses both xml::reader::Error
and xml::writer::Error
(e.g. a function that processes an input XML file and outputs a different XML file). In that case, the code needs to handle two different error structures. The workaround is relatively easy, I can write my own error enum that wraps both read/write errors, together with the From
trait implementations. This way, my code can use the ?
operator on both xml::reader
and xml::writer
code.
Maybe this should be provided out of the box by the xml-rs
library? Otherwise everyone who is writing an xml transformation function will have to re-invent it.
#[derive(Debug)]
pub enum XmlError {
ReadError(xml::reader::Error),
WriterError(xml::writer::Error)
}
impl From<xml::reader::Error> for XmlError {
fn from(value: xml::reader::Error) -> Self {
Self::ReadError(value)
}
}
impl From<xml::writer::Error> for XmlError {
fn from(value: xml::writer::Error) -> Self {
Self::WriterError(value)
}
}
Metadata
Metadata
Assignees
Labels
No labels