Skip to main content

consortium_nix/
error.rs

1//! Error types for NixOS deployment operations.
2
3use std::path::PathBuf;
4
5/// Errors from NixOS deployment operations.
6#[derive(Debug, thiserror::Error)]
7pub enum NixError {
8    #[error("nix evaluation failed for {host}: {message}")]
9    EvalFailed { host: String, message: String },
10
11    #[error("nix build failed for {host}: {message}")]
12    BuildFailed { host: String, message: String },
13
14    #[error("closure copy failed to {host}: {message}")]
15    CopyFailed { host: String, message: String },
16
17    #[error("activation failed on {host}: {message}")]
18    ActivationFailed { host: String, message: String },
19
20    #[error("SSH connection failed to {host}: {message}")]
21    SshFailed { host: String, message: String },
22
23    #[error("builder {host} is unhealthy: {message}")]
24    UnhealthyBuilder { host: String, message: String },
25
26    #[error("no healthy builders available")]
27    NoHealthyBuilders,
28
29    #[error("configuration error: {0}")]
30    Config(#[from] crate::config::ConfigError),
31
32    #[error("IO error: {0}")]
33    Io(#[from] std::io::Error),
34
35    #[error("failed to write machines file to {path}: {source}")]
36    MachinesFile {
37        path: PathBuf,
38        source: std::io::Error,
39    },
40
41    #[error("{0}")]
42    General(String),
43}
44
45pub type Result<T> = std::result::Result<T, NixError>;