Skip to main content

zeph_experiments/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Error types for the experiments module.
5
6/// Errors that can occur during benchmark evaluation.
7#[derive(Debug, thiserror::Error)]
8pub enum EvalError {
9    #[error("failed to load benchmark file {0}: {1}")]
10    BenchmarkLoad(String, #[source] std::io::Error),
11
12    #[error("failed to parse benchmark file {0}: {1}")]
13    BenchmarkParse(String, String),
14
15    #[error("benchmark set is empty")]
16    EmptyBenchmarkSet,
17
18    #[error("evaluation budget exceeded: used {used} of {budget} tokens")]
19    BudgetExceeded { used: u64, budget: u64 },
20
21    #[error("LLM error during evaluation: {0}")]
22    Llm(#[from] zeph_llm::LlmError),
23
24    #[error("judge output parse failed for case {case_index}: {detail}")]
25    JudgeParse { case_index: usize, detail: String },
26
27    #[error("semaphore acquire failed: {0}")]
28    Semaphore(String),
29
30    #[error("benchmark file exceeds size limit ({size} bytes > {limit} bytes): {path}")]
31    BenchmarkTooLarge { path: String, size: u64, limit: u64 },
32
33    #[error("benchmark file path escapes allowed directory: {0}")]
34    PathTraversal(String),
35
36    #[error("parameter out of range: {kind} value {value} not in [{min}, {max}]")]
37    OutOfRange {
38        kind: String,
39        value: f64,
40        min: f64,
41        max: f64,
42    },
43
44    #[error("search space exhausted: all variations in {strategy} have been visited")]
45    SearchSpaceExhausted { strategy: &'static str },
46
47    #[error("invalid neighborhood radius {radius}: must be finite and positive")]
48    InvalidRadius { radius: f64 },
49
50    #[error("experiment storage error: {0}")]
51    Storage(String),
52}