use std::{error, fmt};
use fbxcel::{low::FbxVersion, tree};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
UnsupportedVersion(FbxVersion),
Tree(tree::any::Error),
Dom(Box<dyn error::Error + Send + Sync + 'static>),
}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::Tree(e) => Some(e),
Error::Dom(e) => Some(&**e),
Error::UnsupportedVersion(..) => None,
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Tree(e) => write!(f, "Tree load error: {}", e),
Error::Dom(e) => write!(f, "DOM document load error: {}", e),
Error::UnsupportedVersion(ver) => write!(f, "Unsupported FBX version: {:?}", ver),
}
}
}
impl From<tree::any::Error> for Error {
fn from(e: tree::any::Error) -> Self {
Error::Tree(e)
}
}
impl From<crate::v7400::LoadError> for Error {
fn from(e: crate::v7400::LoadError) -> Self {
Error::Dom(e.into())
}
}