rig_retrieval_evals/error.rs
1//! Error types for `rig-retrieval-evals`.
2
3use rig::vector_store::VectorStoreError;
4
5/// Errors produced by `rig-retrieval-evals`.
6#[derive(Debug, thiserror::Error)]
7pub enum Error {
8 /// Failed to parse a qrels / corpus / answers JSONL file.
9 #[error("dataset parse error at line {line}: {source}")]
10 DatasetParse {
11 /// 1-indexed source line that failed to parse.
12 line: usize,
13 /// The underlying JSON error.
14 #[source]
15 source: serde_json::Error,
16 },
17
18 /// I/O error while reading or writing a dataset or report.
19 #[error("i/o error: {0}")]
20 Io(#[from] std::io::Error),
21
22 /// JSON (de)serialization error outside dataset parsing (e.g. report
23 /// writing or qrels round-trip).
24 #[error("json error: {0}")]
25 Json(#[from] serde_json::Error),
26
27 /// The underlying [`rig::vector_store::VectorStoreIndex`] returned an
28 /// error during a retrieval run.
29 #[error("vector store error: {0}")]
30 Store(#[from] VectorStoreError),
31
32 /// An LLM [`Extractor`](rig::extractor::Extractor) invocation failed
33 /// inside a RAGAS judge.
34 #[cfg(feature = "ragas")]
35 #[error("extractor error: {0}")]
36 Extraction(#[from] rig::extractor::ExtractionError),
37
38 /// An embedding-model invocation failed inside a judge or novelty adapter.
39 #[cfg(any(feature = "ragas", feature = "embedding-novelty"))]
40 #[error("embedding error: {0}")]
41 Embedding(#[from] rig::embeddings::EmbeddingError),
42
43 /// The configured top-k or sample count was invalid (e.g. zero).
44 #[error("invalid configuration: {0}")]
45 Config(String),
46
47 /// A metric requested a comparison against a baseline whose schema does
48 /// not match the current report (different judge fingerprint, different
49 /// metric set, etc.).
50 #[error("baseline mismatch: {0}")]
51 BaselineMismatch(String),
52
53 /// An ingestion-pipeline filter (IoC, graph, proposition) failed to
54 /// evaluate a document. The reason carries the failing track and a
55 /// human-readable cause; the offending document is identified by the
56 /// caller's `Document::id`.
57 #[cfg(feature = "ingestion")]
58 #[error("ingestion error: {0}")]
59 Ingestion(String),
60}
61
62/// Convenience alias.
63pub type Result<T, E = Error> = std::result::Result<T, E>;