Skip to main content

zeph_bench/
error.rs

1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4/// Errors produced by the benchmark harness.
5///
6/// All fallible public functions in `zeph-bench` return `Result<T, BenchError>`.
7///
8/// # Examples
9///
10/// ```
11/// use zeph_bench::BenchError;
12///
13/// fn example() -> Result<(), BenchError> {
14///     Err(BenchError::DatasetNotFound("tau-bench".into()))
15/// }
16///
17/// assert!(example().is_err());
18/// ```
19#[derive(Debug, thiserror::Error)]
20pub enum BenchError {
21    /// A named dataset was requested but is not registered in [`crate::DatasetRegistry`].
22    #[error("dataset not found: {0}")]
23    DatasetNotFound(String),
24
25    /// An I/O error occurred while reading or writing a dataset or results file.
26    #[error("dataset I/O error: {0}")]
27    Io(#[from] std::io::Error),
28
29    /// The dataset file could not be parsed (wrong schema, corrupt JSON/JSONL, etc.).
30    ///
31    /// The inner `String` carries a human-readable description that includes the line
32    /// number for JSONL formats.
33    #[error("invalid dataset format: {0}")]
34    InvalidFormat(String),
35
36    /// An error propagated from the [`zeph_core::channel::Channel`] implementation.
37    #[error("channel error: {0}")]
38    Channel(#[from] zeph_core::channel::ChannelError),
39
40    /// A catch-all variant for errors that do not fit the above categories.
41    #[error("{0}")]
42    Other(String),
43}