Skip to main content

harness_locate/
error.rs

1//! Error types for harness operations.
2
3use std::path::PathBuf;
4
5/// Errors that can occur during harness operations.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9    /// The requested harness was not found on this system.
10    #[error("harness not found: {0}")]
11    NotFound(String),
12
13    /// The path is invalid or inaccessible.
14    #[error("invalid path: {0}")]
15    InvalidPath(PathBuf),
16
17    /// An environment variable could not be read.
18    #[error("environment variable error: {0}")]
19    EnvVar(#[from] std::env::VarError),
20
21    /// The current platform is not supported.
22    #[error("unsupported platform")]
23    UnsupportedPlatform,
24
25    /// An I/O error occurred.
26    #[error("IO error: {0}")]
27    Io(#[from] std::io::Error),
28
29    /// MCP server uses unsupported features for target harness.
30    #[error("unsupported MCP config for {harness}: {reason}")]
31    UnsupportedMcpConfig {
32        /// The harness that doesn't support the config.
33        harness: String,
34        /// Explanation of what's unsupported.
35        reason: String,
36    },
37
38    /// Binary detection failed due to system error.
39    #[error("binary detection error: {0}")]
40    BinaryDetection(String),
41
42    /// The requested scope is not supported by this harness.
43    #[error("{harness} does not support {scope} scope")]
44    UnsupportedScope { harness: String, scope: String },
45
46    /// YAML parsing failed.
47    #[error("YAML parse error: {0}")]
48    YamlParse(#[from] serde_yaml::Error),
49
50    /// A required field is missing from the input.
51    #[error("missing required field: {0}")]
52    MissingField(String),
53
54    /// An environment variable referenced by EnvValue is not set.
55    #[error("missing environment variable: {name}")]
56    MissingEnvVar {
57        /// The name of the environment variable that was not set.
58        name: String,
59    },
60}
61
62/// A specialized Result type for harness operations.
63pub type Result<T> = std::result::Result<T, Error>;