Skip to content

Commit

Permalink
Add ioError to DeError
Browse files Browse the repository at this point in the history
This handles Writer now returning `std::io::Error`
  • Loading branch information
RedPhoenixQ committed Sep 28, 2024
1 parent 6d47998 commit 1afe6d0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ pub mod serialize {
pub enum DeError {
/// Serde custom error
Custom(String),
/// IO error from Writer
Io(Arc<IoError>),
/// Xml parsing error
InvalidXml(Error),
/// Cannot parse to integer
Expand Down Expand Up @@ -368,6 +370,7 @@ pub mod serialize {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
DeError::Custom(s) => write!(f, "{}", s),
DeError::Io(e) => write!(f, "{}", e),
DeError::InvalidXml(e) => write!(f, "{}", e),
DeError::InvalidInt(e) => write!(f, "{}", e),
DeError::InvalidFloat(e) => write!(f, "{}", e),
Expand Down Expand Up @@ -409,6 +412,13 @@ pub mod serialize {
}
}

impl From<IoError> for DeError {
#[inline]
fn from(e: IoError) -> Self {
Self::Io(Arc::new(e))
}
}

impl From<Error> for DeError {
#[inline]
fn from(e: Error) -> Self {
Expand Down

0 comments on commit 1afe6d0

Please sign in to comment.