fbxcel_dom/v7400/error/
load.rs1use std::{error, fmt};
4
5use fbxcel::tree::v7400::LoadError as TreeLoadError;
6
7#[derive(Debug)]
9pub struct LoadError(Box<dyn error::Error + Send + Sync + 'static>);
10
11impl LoadError {
12 pub(crate) fn new(e: impl Into<Box<dyn error::Error + Send + Sync + 'static>>) -> Self {
14 Self(e.into())
15 }
16}
17
18impl fmt::Display for LoadError {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 self.0.fmt(f)
21 }
22}
23
24impl error::Error for LoadError {
25 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
26 Some(&*self.0)
27 }
28}
29
30impl From<TreeLoadError> for LoadError {
31 fn from(e: TreeLoadError) -> Self {
32 Self::new(e)
33 }
34}
35
36#[derive(Debug)]
38#[allow(clippy::enum_variant_names)]
39pub(crate) enum StructureError {
40 MissingConnectionsNode,
42 MissingDocumentsNode,
44 MissingObjectsNode,
46}
47
48impl fmt::Display for StructureError {
49 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 match self {
51 StructureError::MissingConnectionsNode => {
52 f.write_str("Toplevel `Connections` node not found")
53 }
54 StructureError::MissingDocumentsNode => {
55 f.write_str("Toplevel `Documents` node not found")
56 }
57 StructureError::MissingObjectsNode => f.write_str("Toplevel `Objects` node not found"),
58 }
59 }
60}
61
62impl error::Error for StructureError {}
63
64impl From<StructureError> for LoadError {
65 fn from(e: StructureError) -> Self {
66 Self::new(e)
67 }
68}