use std::error::Error;
use std::fmt;
use crate::error::{InternalError, InvalidArgumentError};
#[derive(Debug)]
pub enum ProductGdsnError {
Internal(InternalError),
InvalidArgument(InvalidArgumentError),
}
impl Error for ProductGdsnError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
ProductGdsnError::Internal(err) => Some(err),
ProductGdsnError::InvalidArgument(err) => Some(err),
}
}
}
impl fmt::Display for ProductGdsnError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ProductGdsnError::Internal(err) => err.fmt(f),
ProductGdsnError::InvalidArgument(err) => err.fmt(f),
}
}
}
impl From<quick_xml::Error> for ProductGdsnError {
fn from(err: quick_xml::Error) -> Self {
ProductGdsnError::Internal(InternalError::from_source(Box::new(err)))
}
}
impl From<std::str::Utf8Error> for ProductGdsnError {
fn from(err: std::str::Utf8Error) -> Self {
ProductGdsnError::Internal(InternalError::from_source(Box::new(err)))
}
}
impl From<crate::protocol::schema::state::PropertyValueBuildError> for ProductGdsnError {
fn from(err: crate::protocol::schema::state::PropertyValueBuildError) -> Self {
ProductGdsnError::Internal(InternalError::from_source(Box::new(err)))
}
}
impl From<crate::protocol::errors::BuilderError> for ProductGdsnError {
fn from(err: crate::protocol::errors::BuilderError) -> Self {
ProductGdsnError::Internal(InternalError::from_source(Box::new(err)))
}
}