2017-03-08 19:34:17 +00:00
|
|
|
//! Provides an error type for this crate.
|
|
|
|
|
2017-02-19 19:46:44 +00:00
|
|
|
use std::io;
|
|
|
|
|
|
|
|
use std::convert::From;
|
|
|
|
|
|
|
|
use xml::writer::Error as WriterError;
|
|
|
|
use xml::reader::Error as ReaderError;
|
|
|
|
|
2017-02-21 14:46:06 +00:00
|
|
|
/// An enum representing the possible errors.
|
2017-02-19 19:46:44 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Error {
|
2017-03-08 19:34:17 +00:00
|
|
|
/// An io::Error.
|
2017-02-19 19:46:44 +00:00
|
|
|
IoError(io::Error),
|
2017-03-08 19:34:17 +00:00
|
|
|
/// An error in the xml-rs `EventWriter`.
|
2017-02-19 19:46:44 +00:00
|
|
|
XmlWriterError(WriterError),
|
2017-03-08 19:34:17 +00:00
|
|
|
/// An error in the xml-rs `EventReader`.
|
2017-02-19 19:46:44 +00:00
|
|
|
XmlReaderError(ReaderError),
|
2017-03-08 19:34:17 +00:00
|
|
|
/// The end of the document has been reached unexpectedly.
|
2017-02-19 19:46:44 +00:00
|
|
|
EndOfDocument,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<io::Error> for Error {
|
|
|
|
fn from(err: io::Error) -> Error {
|
|
|
|
Error::IoError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<WriterError> for Error {
|
|
|
|
fn from(err: WriterError) -> Error {
|
|
|
|
Error::XmlWriterError(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<ReaderError> for Error {
|
|
|
|
fn from(err: ReaderError) -> Error {
|
|
|
|
Error::XmlReaderError(err)
|
|
|
|
}
|
|
|
|
}
|