1use crate::Time;
4
5#[cfg(feature = "builtin-types")]
6use crate::DataType;
7
8#[derive(Debug, Clone, thiserror::Error)]
10pub enum Error {
11 #[cfg(feature = "builtin-types")]
13 #[error("{method}: called on incompatible type `{got:?}`")]
14 IncompatibleType {
15 method: &'static str,
17 got: DataType,
19 },
20
21 #[cfg(feature = "builtin-types")]
23 #[error("cannot convert `{from:?}` to `{to:?}`")]
24 ConversionUnsupported {
25 from: DataType,
27 to: DataType,
29 },
30
31 #[error("cannot parse '{input}' as {target_type}")]
33 ParseFailed {
34 input: String,
36 target_type: &'static str,
38 },
39
40 #[error("integer conversion error: {0}")]
42 IntegerOverflow(#[from] std::num::TryFromIntError),
43
44 #[error("cannot create animated value with no samples")]
46 EmptySamples,
47
48 #[error("cannot remove the last sample from animated data")]
50 LastSample,
51
52 #[cfg(feature = "builtin-types")]
54 #[error("animated sample type mismatch: expected `{expected:?}`, got `{got:?}` at time {time}")]
55 AnimatedTypeMismatch {
56 expected: DataType,
58 got: DataType,
60 time: Time,
62 },
63
64 #[error("vector length {actual} exceeds expected {expected} at time {time}")]
66 VectorLengthExceeded {
67 actual: usize,
69 expected: usize,
71 time: Time,
73 },
74
75 #[cfg(feature = "builtin-types")]
77 #[error("cannot add `{got:?}` to animated `{expected:?}`")]
78 SampleTypeMismatch {
79 expected: DataType,
81 got: DataType,
83 },
84
85 #[error("cannot set interpolation on uniform value")]
87 InterpolationOnUniform,
88
89 #[cfg(feature = "builtin-types")]
91 #[error("bezier handles only supported for Real type, got `{got:?}`")]
92 BezierNotSupported {
93 got: DataType,
95 },
96
97 #[cfg(feature = "builtin-types")]
99 #[error("Sample<{sample_type}> called on `{got:?}` variant")]
100 SampleVariantMismatch {
101 sample_type: &'static str,
103 got: DataType,
105 },
106
107 #[error("{type_name} cannot be empty")]
109 EmptyVec {
110 type_name: &'static str,
112 },
113
114 #[error("key not found in data map")]
116 KeyNotFound,
117
118 #[error("cannot extract {type_name} from animated Value")]
120 AnimatedExtraction {
121 type_name: &'static str,
123 },
124
125 #[error("type mismatch: expected {expected}, got {got}")]
127 GenericTypeMismatch {
128 expected: &'static str,
130 got: &'static str,
132 },
133}
134
135pub type Result<T> = std::result::Result<T, Error>;