1use thiserror::Error;
4
5#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum AttunedError {
9 #[error("validation error: {0}")]
11 Validation(#[from] ValidationError),
12
13 #[error("storage error: {0}")]
15 Storage(String),
16
17 #[error("serialization error: {0}")]
19 Serialization(#[from] serde_json::Error),
20}
21
22#[derive(Debug, Error, PartialEq)]
24#[non_exhaustive]
25pub enum ValidationError {
26 #[error("axis '{axis}' has value {value} outside valid range [0.0, 1.0]")]
28 AxisOutOfRange {
29 axis: String,
31 value: f32,
33 },
34
35 #[error("axis name '{axis}' contains invalid characters (must be lowercase alphanumeric with underscores)")]
37 InvalidAxisName {
38 axis: String,
40 },
41
42 #[error("user_id cannot be empty")]
44 EmptyUserId,
45
46 #[error("user_id exceeds maximum length of {max} characters")]
48 UserIdTooLong {
49 max: usize,
51 },
52
53 #[error("user_id contains invalid characters (must be alphanumeric, underscore, or hyphen)")]
55 InvalidUserIdChars,
56
57 #[error("confidence {value} is outside valid range [0.0, 1.0]")]
59 ConfidenceOutOfRange {
60 value: f32,
62 },
63
64 #[error("missing required field: {field}")]
66 MissingField {
67 field: String,
69 },
70}