various: nicer error handling
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ib6f474603196a32df6e9745e74d0744f6a6a6964
This commit is contained in:
parent
185403436b
commit
2739462ec0
2 changed files with 27 additions and 29 deletions
|
|
@ -70,10 +70,9 @@ impl NixFileFixer for DefaultNixFileFixer {
|
|||
.collect();
|
||||
|
||||
if files.is_empty() {
|
||||
Err(EhError::NoNixFilesFound)
|
||||
} else {
|
||||
Ok(files)
|
||||
return Err(EhError::NoNixFilesFound);
|
||||
}
|
||||
Ok(files)
|
||||
}
|
||||
|
||||
fn fix_hash_in_file(&self, file_path: &Path, new_hash: &str) -> Result<bool> {
|
||||
|
|
@ -275,7 +274,9 @@ pub fn handle_nix_with_retry(
|
|||
}
|
||||
|
||||
// Otherwise, show the error and return error
|
||||
std::io::stderr().write_all(&output.stderr)?;
|
||||
std::io::stderr()
|
||||
.write_all(&output.stderr)
|
||||
.map_err(EhError::Io)?;
|
||||
Err(EhError::ProcessExit {
|
||||
code: output.status.code().unwrap_or(1),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -97,15 +97,7 @@ fn create_multicall_binaries(
|
|||
fs::remove_file(&target_path)?;
|
||||
}
|
||||
|
||||
match fs::hard_link(main_binary, &target_path) {
|
||||
Ok(()) => {
|
||||
println!(
|
||||
" created hardlink: {} points to {}",
|
||||
target_path.display(),
|
||||
main_binary.display(),
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
if let Err(e) = fs::hard_link(main_binary, &target_path) {
|
||||
eprintln!(
|
||||
" warning: could not create hardlink for {}: {e}",
|
||||
binary.name(),
|
||||
|
|
@ -123,7 +115,12 @@ fn create_multicall_binaries(
|
|||
}
|
||||
|
||||
println!(" created copy: {}", target_path.display());
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
" created hardlink: {} points to {}",
|
||||
target_path.display(),
|
||||
main_binary.display(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue