adk_bench/error.rs
1//! Error types for the `adk-bench` benchmarking framework.
2
3use thiserror::Error;
4
5/// Errors that can occur during benchmark execution.
6#[derive(Debug, Error)]
7pub enum BenchError {
8 /// Workload JSON failed schema validation.
9 #[error("Workload validation failed for field '{field}': {reason}")]
10 WorkloadValidation {
11 /// The field that failed validation.
12 field: String,
13 /// Description of the validation failure.
14 reason: String,
15 },
16
17 /// Workload file was not found at the specified path.
18 #[error("Workload file not found: {path}")]
19 WorkloadNotFound {
20 /// The path that was attempted.
21 path: String,
22 },
23
24 /// An external framework benchmark subprocess failed.
25 #[error("External runner '{framework}' failed: {reason}")]
26 ExternalRunner {
27 /// The framework that failed.
28 framework: String,
29 /// Description of the failure.
30 reason: String,
31 },
32
33 /// An external framework benchmark subprocess exceeded its timeout.
34 #[error("External runner '{framework}' timed out after {timeout_secs}s")]
35 ExternalTimeout {
36 /// The framework that timed out.
37 framework: String,
38 /// The timeout duration in seconds.
39 timeout_secs: u64,
40 },
41
42 /// An LLM API call failed during benchmark execution.
43 #[error("LLM call failed: {0}")]
44 Llm(String),
45
46 /// A baseline persistence operation failed.
47 #[error("Baseline operation failed: {0}")]
48 Baseline(String),
49
50 /// Serialization or deserialization of benchmark data failed.
51 #[error("Serialization error: {0}")]
52 Serialization(String),
53
54 /// Memory sampling is unavailable on the current platform.
55 #[error("Memory sampling unavailable on this platform: {0}")]
56 MemoryUnavailable(String),
57
58 /// An I/O error occurred.
59 #[error("IO error: {0}")]
60 Io(#[from] std::io::Error),
61}
62
63/// A specialized Result type for benchmark operations.
64pub type Result<T> = std::result::Result<T, BenchError>;