herolib_code/rust_builder/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4/// Errors that can occur during Rust building operations.
5#[derive(Debug, Error)]
6pub enum RustBuilderError {
7    /// Cargo.toml not found starting from the given path
8    #[error("Cargo.toml not found starting from '{path}'")]
9    CargoTomlNotFound { path: PathBuf },
10
11    /// Failed to parse Cargo.toml
12    #[error("Failed to parse Cargo.toml at '{path}': {message}")]
13    CargoTomlParseError { path: PathBuf, message: String },
14
15    /// Build command failed
16    #[error("Build failed with exit code {code}: {stderr}")]
17    BuildFailed { code: i32, stderr: String },
18
19    /// Binary not found in project
20    #[error("Binary '{name}' not found in project")]
21    BinaryNotFound { name: String },
22
23    /// Artifact not found at expected path
24    #[error("Artifact not found at expected path '{path}'")]
25    ArtifactNotFound { path: PathBuf },
26
27    /// Failed to copy artifact
28    #[error("Failed to copy artifact: {message}")]
29    CopyFailed { message: String },
30
31    /// IO error
32    #[error("IO error: {0}")]
33    Io(#[from] std::io::Error),
34
35    /// Path does not exist
36    #[error("Path '{path}' does not exist")]
37    PathNotFound { path: PathBuf },
38
39    /// TOML parsing error
40    #[error("TOML error: {0}")]
41    TomlError(#[from] toml::de::Error),
42
43    /// Invalid configuration
44    #[error("Invalid configuration: {0}")]
45    InvalidConfig(String),
46}
47
48pub type BuilderResult<T> = Result<T, RustBuilderError>;