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 #[cfg(feature = "builtin-types")]
50 #[error("animated sample type mismatch: expected `{expected:?}`, got `{got:?}` at time {time}")]
51 AnimatedTypeMismatch {
52 expected: DataType,
54 got: DataType,
56 time: Time,
58 },
59
60 #[error("vector length {actual} exceeds expected {expected} at time {time}")]
62 VectorLengthExceeded {
63 actual: usize,
65 expected: usize,
67 time: Time,
69 },
70
71 #[cfg(feature = "builtin-types")]
73 #[error("cannot add `{got:?}` to animated `{expected:?}`")]
74 SampleTypeMismatch {
75 expected: DataType,
77 got: DataType,
79 },
80
81 #[error("cannot set interpolation on uniform value")]
83 InterpolationOnUniform,
84
85 #[cfg(feature = "builtin-types")]
87 #[error("bezier handles only supported for Real type, got `{got:?}`")]
88 BezierNotSupported {
89 got: DataType,
91 },
92
93 #[cfg(feature = "builtin-types")]
95 #[error("Sample<{sample_type}> called on `{got:?}` variant")]
96 SampleVariantMismatch {
97 sample_type: &'static str,
99 got: DataType,
101 },
102
103 #[error("{type_name} cannot be empty")]
105 EmptyVec {
106 type_name: &'static str,
108 },
109
110 #[error("time {time} not found in animated data")]
112 TimeNotFound {
113 time: Time,
115 },
116
117 #[error("cannot extract {type_name} from animated Value")]
119 AnimatedExtraction {
120 type_name: &'static str,
122 },
123
124 #[error("type mismatch: expected {expected}, got {got}")]
126 GenericTypeMismatch {
127 expected: &'static str,
129 got: &'static str,
131 },
132}
133
134pub type Result<T> = std::result::Result<T, Error>;