Improve error handling.
This commit is contained in:
parent
36250cf6fa
commit
2f8a9ba967
2 changed files with 7 additions and 4 deletions
|
|
@ -209,7 +209,11 @@ where
|
||||||
) -> EtcActivationResult {
|
) -> EtcActivationResult {
|
||||||
let link_path = etc_dir.join(link_target);
|
let link_path = etc_dir.join(link_target);
|
||||||
// Create the dir if it doesn't exist yet
|
// Create the dir if it doesn't exist yet
|
||||||
let dir_state = create_dir_recursively(&link_path, state)?;
|
let dir_state = if !link_path.exists() {
|
||||||
|
create_dir_recursively(&link_path, state)?
|
||||||
|
} else {
|
||||||
|
state
|
||||||
|
};
|
||||||
log::debug!("Entering into directory {}...", link_path.display());
|
log::debug!("Entering into directory {}...", link_path.display());
|
||||||
Ok(absolute_target
|
Ok(absolute_target
|
||||||
.read_dir()
|
.read_dir()
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,7 @@ fn get_store_path(nix_build_result: process::Output) -> Result<StorePath> {
|
||||||
.map_err(|e| anyhow::anyhow!(e).context("Error reading nix build output."))
|
.map_err(|e| anyhow::anyhow!(e).context("Error reading nix build output."))
|
||||||
.and_then(parse_nix_build_output)
|
.and_then(parse_nix_build_output)
|
||||||
} else {
|
} else {
|
||||||
String::from_utf8(nix_build_result.stderr)
|
anyhow::bail!("Nix build failed, see console output for details.")
|
||||||
.map_err(anyhow::Error::from)
|
|
||||||
.and_then(|e| Err(anyhow::anyhow!(e).context("Nix build failed.")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,6 +156,7 @@ fn try_nix_eval(flake: &str, attr: &str) -> Result<bool> {
|
||||||
.arg("--json")
|
.arg("--json")
|
||||||
.arg("--apply")
|
.arg("--apply")
|
||||||
.arg(format!("a: a ? {attr}"))
|
.arg(format!("a: a ? {attr}"))
|
||||||
|
.stderr(process::Stdio::inherit())
|
||||||
.output()?;
|
.output()?;
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
let stdout = String::from_utf8(output.stdout)?;
|
let stdout = String::from_utf8(output.stdout)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue