rbx_types/
error.rs

1use thiserror::Error;
2
3use crate::{AttributeError, MaterialColorsError, Matrix3Error, UniqueIdError};
4
5/// Represents an error that occurred when using a fallible method.
6#[derive(Debug, Error)]
7#[error(transparent)]
8pub struct Error {
9    source: Box<InnerError>,
10}
11
12impl From<AttributeError> for Error {
13    fn from(source: AttributeError) -> Self {
14        Self {
15            source: Box::new(source.into()),
16        }
17    }
18}
19
20impl From<Matrix3Error> for Error {
21    fn from(source: Matrix3Error) -> Self {
22        Self {
23            source: Box::new(source.into()),
24        }
25    }
26}
27
28impl From<MaterialColorsError> for Error {
29    fn from(source: MaterialColorsError) -> Self {
30        Self {
31            source: Box::new(source.into()),
32        }
33    }
34}
35
36impl From<UniqueIdError> for Error {
37    fn from(source: UniqueIdError) -> Self {
38        Self {
39            source: Box::new(source.into()),
40        }
41    }
42}
43
44#[derive(Debug, Error)]
45enum InnerError {
46    #[error(transparent)]
47    Attribute(#[from] AttributeError),
48
49    #[error(transparent)]
50    Matrix3(#[from] Matrix3Error),
51
52    #[error(transparent)]
53    MaterialColors(#[from] MaterialColorsError),
54
55    #[error(transparent)]
56    UniqueId(#[from] UniqueIdError),
57}