fbxcel/pull_parser/any/
error.rs

1//! Error and result types for `pull_parser::any` module.
2
3use std::{error, fmt};
4
5use crate::low::{FbxVersion, HeaderError};
6
7/// AnyTree load result.
8pub type Result<T> = std::result::Result<T, Error>;
9
10/// Error.
11#[derive(Debug)]
12#[non_exhaustive]
13pub enum Error {
14    /// Header error.
15    Header(HeaderError),
16    /// Unsupported version.
17    UnsupportedVersion(FbxVersion),
18}
19
20impl error::Error for Error {
21    #[inline]
22    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
23        match self {
24            Error::Header(e) => Some(e),
25            _ => None,
26        }
27    }
28}
29
30impl fmt::Display for Error {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        match self {
33            Error::Header(e) => write!(f, "FBX header error: {}", e),
34            Error::UnsupportedVersion(ver) => write!(f, "Unsupported FBX version: {:?}", ver),
35        }
36    }
37}
38
39impl From<HeaderError> for Error {
40    #[inline]
41    fn from(e: HeaderError) -> Self {
42        Error::Header(e)
43    }
44}