1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! Error types for token-value-map operations.
use crate::Time;
#[cfg(feature = "builtin-types")]
use crate::DataType;
/// Error type for token-value-map operations.
#[derive(Debug, Clone, thiserror::Error)]
pub enum Error {
/// Type conversion method called on incompatible type.
#[cfg(feature = "builtin-types")]
#[error("{method}: called on incompatible type `{got:?}`")]
IncompatibleType {
/// The method that was called.
method: &'static str,
/// The actual data type encountered.
got: DataType,
},
/// Conversion between data types is not supported.
#[cfg(feature = "builtin-types")]
#[error("cannot convert `{from:?}` to `{to:?}`")]
ConversionUnsupported {
/// The source data type.
from: DataType,
/// The target data type.
to: DataType,
},
/// Failed to parse string as target type.
#[error("cannot parse '{input}' as {target_type}")]
ParseFailed {
/// The input string that failed to parse.
input: String,
/// The target type name.
target_type: &'static str,
},
/// Integer conversion overflow.
#[error("integer conversion error: {0}")]
IntegerOverflow(#[from] std::num::TryFromIntError),
/// Cannot create animated value with no samples.
#[error("cannot create animated value with no samples")]
EmptySamples,
/// Cannot remove the last sample from animated data.
#[error("cannot remove the last sample from animated data")]
LastSample,
/// Type mismatch in animated samples.
#[cfg(feature = "builtin-types")]
#[error("animated sample type mismatch: expected `{expected:?}`, got `{got:?}` at time {time}")]
AnimatedTypeMismatch {
/// The expected data type.
expected: DataType,
/// The actual data type encountered.
got: DataType,
/// The time at which the mismatch occurred.
time: Time,
},
/// Vector length exceeds expected.
#[error("vector length {actual} exceeds expected {expected} at time {time}")]
VectorLengthExceeded {
/// The actual vector length.
actual: usize,
/// The expected maximum length.
expected: usize,
/// The time at which the error occurred.
time: Time,
},
/// Type mismatch when adding sample to animated value.
#[cfg(feature = "builtin-types")]
#[error("cannot add `{got:?}` to animated `{expected:?}`")]
SampleTypeMismatch {
/// The expected data type.
expected: DataType,
/// The actual data type encountered.
got: DataType,
},
/// Cannot set interpolation on uniform value.
#[error("cannot set interpolation on uniform value")]
InterpolationOnUniform,
/// Bezier handles only supported for Real type.
#[cfg(feature = "builtin-types")]
#[error("bezier handles only supported for Real type, got `{got:?}`")]
BezierNotSupported {
/// The actual data type encountered.
got: DataType,
},
/// Sample trait called on wrong variant.
#[cfg(feature = "builtin-types")]
#[error("Sample<{sample_type}> called on `{got:?}` variant")]
SampleVariantMismatch {
/// The expected sample type.
sample_type: &'static str,
/// The actual data type encountered.
got: DataType,
},
/// Vector type cannot be empty.
#[error("{type_name} cannot be empty")]
EmptyVec {
/// The vector type name.
type_name: &'static str,
},
/// Key not found in data map.
#[error("key not found in data map")]
KeyNotFound,
/// Cannot extract value from animated data.
#[error("cannot extract {type_name} from animated Value")]
AnimatedExtraction {
/// The type name.
type_name: &'static str,
},
/// Type mismatch (generic version for custom data systems).
#[error("type mismatch: expected {expected}, got {got}")]
GenericTypeMismatch {
/// The expected type name.
expected: &'static str,
/// The actual type name.
got: &'static str,
},
}
/// Result type alias using the crate's [`Error`] type.
pub type Result<T> = std::result::Result<T, Error>;