Skip to main content

baracuda_forge/
error.rs

1//! Error types for baracuda-forge.
2
3use std::path::PathBuf;
4use thiserror::Error;
5
6/// Result type alias for baracuda-forge operations.
7pub type Result<T> = std::result::Result<T, Error>;
8
9/// Errors that can occur during CUDA kernel building.
10#[derive(Debug, Error)]
11pub enum Error {
12    /// nvcc binary not found.
13    #[error("nvcc not found: {0}. Set NVCC environment variable or ensure nvcc is in PATH")]
14    NvccNotFound(String),
15
16    /// CUDA toolkit not found.
17    #[error("CUDA toolkit not found at {0}")]
18    CudaToolkitNotFound(PathBuf),
19
20    /// Compute capability detection failed.
21    #[error("Failed to detect compute capability: {0}")]
22    ComputeCapDetectionFailed(String),
23
24    /// Kernel compilation failed.
25    #[error("Kernel compilation failed for {path}: {message}")]
26    CompilationFailed {
27        /// Path to the kernel file that failed.
28        path: PathBuf,
29        /// Error message from nvcc.
30        message: String,
31    },
32
33    /// Linking failed.
34    #[error("Linking failed: {0}")]
35    LinkingFailed(String),
36
37    /// Invalid source path.
38    #[error("Source path does not exist: {0}")]
39    SourcePathNotFound(PathBuf),
40
41    /// Git operation failed.
42    #[error("Git operation failed: {0}")]
43    GitOperationFailed(String),
44
45    /// IO error.
46    #[error("IO error: {0}")]
47    Io(#[from] std::io::Error),
48
49    /// Cache error.
50    #[error("Cache error: {0}")]
51    CacheError(String),
52
53    /// Invalid configuration.
54    #[error("Invalid configuration: {0}")]
55    InvalidConfig(String),
56}