triplets/errors.rs
1use std::io;
2
3use thiserror::Error;
4
5use crate::types::SourceId;
6
7/// Error type for sampler configuration, IO, and persistence failures.
8#[derive(Debug, Error)]
9pub enum SamplerError {
10 /// Source could not be refreshed or reached.
11 #[error("data source '{source_id}' is unavailable: {reason}")]
12 SourceUnavailable {
13 /// Identifier of the failing source.
14 source_id: SourceId,
15 /// Human-readable failure reason.
16 reason: String,
17 },
18 /// Source returned internally inconsistent state.
19 #[error("data source '{source_id}' returned inconsistent state: {details}")]
20 SourceInconsistent {
21 /// Identifier of the inconsistent source.
22 source_id: SourceId,
23 /// Details about what invariant was violated.
24 details: String,
25 },
26 /// Split-store persistence or decoding failure.
27 #[error("split store failure: {0}")]
28 SplitStore(String),
29 /// Underlying IO error.
30 #[error(transparent)]
31 Io(#[from] io::Error),
32 /// Invalid or conflicting configuration.
33 #[error("configuration error: {0}")]
34 Configuration(String),
35 /// Sampling exhausted eligible candidates for a requested recipe/split.
36 #[error("no eligible samples available for recipe '{0}'")]
37 Exhausted(String),
38 /// A weight map entry references an unknown source ID or contains a negative value.
39 #[error("invalid weight for source '{source_id}': {reason}")]
40 InvalidWeight {
41 /// The source ID that triggered the error.
42 source_id: SourceId,
43 /// Human-readable explanation.
44 reason: String,
45 },
46}