1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum LoomError {
8 #[error("invalid cpuset format: {0}")]
10 InvalidCpuSet(String),
11
12 #[error("CPU {0} is not available on this system")]
14 CpuNotAvailable(usize),
15
16 #[error("no CPUs available after applying constraints")]
18 NoCpusAvailable,
19
20 #[error("configuration error: {0}")]
22 Config(#[from] Box<figment::Error>),
23
24 #[error("failed to build tokio runtime: {0}")]
26 TokioRuntime(#[from] std::io::Error),
27
28 #[error("failed to build rayon thread pool: {0}")]
30 RayonThreadPool(#[from] rayon::ThreadPoolBuildError),
31
32 #[error("failed to set thread affinity for CPU {0}")]
34 AffinityFailed(usize),
35
36 #[cfg(feature = "cuda")]
38 #[error("CUDA error: {0}")]
39 Cuda(String),
40
41 #[cfg(feature = "cuda")]
43 #[error("NVML error: {0}")]
44 Nvml(#[from] nvml_wrapper::error::NvmlError),
45
46 #[error("requested {requested} threads but only {available} CPUs available")]
48 InsufficientCpus { requested: usize, available: usize },
49}
50
51pub type Result<T> = std::result::Result<T, LoomError>;