lix-installer/src/error.rs

57 lines
2.5 KiB
Rust
Raw Normal View History

2022-09-14 22:18:13 +00:00
use serde::de::value::Error;
2022-09-02 23:03:57 +00:00
#[derive(thiserror::Error, Debug)]
pub enum HarmonicError {
2022-09-09 19:07:34 +00:00
#[error("Request error")]
2022-09-09 18:43:35 +00:00
Reqwest(#[from] reqwest::Error),
#[error("Unarchiving error")]
Unarchive(std::io::Error),
#[error("Getting temporary directory")]
TempDir(std::io::Error),
#[error("Glob pattern error")]
GlobPatternError(#[from] glob::PatternError),
#[error("Glob globbing error")]
GlobGlobError(#[from] glob::GlobError),
#[error("Symlinking from `{0}` to `{1}`")]
Symlink(std::path::PathBuf, std::path::PathBuf, std::io::Error),
#[error("Renaming from `{0}` to `{1}`")]
Rename(std::path::PathBuf, std::path::PathBuf, std::io::Error),
#[error("Unarchived Nix store did not appear to include a `nss-cacert` location")]
2022-09-08 00:13:06 +00:00
NoNssCacert,
2022-09-09 18:43:35 +00:00
#[error("No supported init system found")]
2022-09-08 00:13:06 +00:00
InitNotSupported,
2022-09-09 18:43:35 +00:00
#[error("Creating directory `{0}`")]
CreateDirectory(std::path::PathBuf, std::io::Error),
#[error("Walking directory `{0}`")]
WalkDirectory(std::path::PathBuf, walkdir::Error),
#[error("Setting permissions `{0}`")]
SetPermissions(std::path::PathBuf, std::io::Error),
2022-09-08 00:13:06 +00:00
#[error("Command `{0}` failed to execute")]
CommandFailedExec(String, std::io::Error),
// TODO(@Hoverbear): This should capture the stdout.
#[error("Command `{0}` did not to return a success status")]
CommandFailedStatus(String),
#[error("Join error")]
JoinError(#[from] tokio::task::JoinError),
2022-09-09 18:43:35 +00:00
#[error("Opening file `{0}` for writing")]
OpenFile(std::path::PathBuf, std::io::Error),
#[error("Opening file `{0}` for writing")]
WriteFile(std::path::PathBuf, std::io::Error),
#[error("Seeking file `{0}` for writing")]
SeekFile(std::path::PathBuf, std::io::Error),
#[error("Changing ownership of `{0}`")]
Chown(std::path::PathBuf, nix::errno::Errno),
#[error("Getting uid for user `{0}`")]
UserId(String, nix::errno::Errno),
#[error("Getting user `{0}`")]
NoUser(String),
#[error("Getting gid for group `{0}`")]
GroupId(String, nix::errno::Errno),
#[error("Getting group `{0}`")]
NoGroup(String),
2022-09-14 22:18:13 +00:00
#[error("Errors with additional failures during reverts: {}\nDuring Revert:{}", .0.iter().map(|v| format!("{v}")).collect::<Vec<_>>().join(" & "), .1.iter().map(|v| format!("{v}")).collect::<Vec<_>>().join(" & "))]
FailedReverts(Vec<HarmonicError>, Vec<HarmonicError>),
#[error("Multiple errors: {}", .0.iter().map(|v| format!("{v}")).collect::<Vec<_>>().join(" & "))]
Multiple(Vec<HarmonicError>)
2022-09-02 23:03:57 +00:00
}