diff --git a/src/error.rs b/src/error.rs index aa50e0d..64b4d0b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -34,8 +34,8 @@ pub enum ColmenaError { #[snafu(display("Validation error"))] ValidationError { errors: ValidationErrors }, - #[snafu(display("Failed to upload keys: {}", error))] - KeyError { error: key::KeyError }, + #[snafu(display("Error processing key \"{}\": {}", name, error))] + KeyError { name: String, error: key::KeyError }, #[snafu(display("Store path {:?} is not a derivation", store_path))] NotADerivation { store_path: StorePath }, @@ -77,12 +77,6 @@ impl From for ColmenaError { } } -impl From for ColmenaError { - fn from(error: key::KeyError) -> Self { - Self::KeyError { error } - } -} - impl From for ColmenaError { fn from(errors: ValidationErrors) -> Self { Self::ValidationError { errors } diff --git a/src/nix/host/key_uploader.rs b/src/nix/host/key_uploader.rs index 216e873..6feaeb8 100644 --- a/src/nix/host/key_uploader.rs +++ b/src/nix/host/key_uploader.rs @@ -12,7 +12,7 @@ use shell_escape::unix::escape; use tokio::io::{AsyncWriteExt, BufReader}; use tokio::process::Child; -use crate::error::ColmenaResult; +use crate::error::{ColmenaError, ColmenaResult}; use crate::job::JobHandle; use crate::nix::Key; use crate::util::capture_stream; @@ -32,7 +32,11 @@ pub fn generate_script<'a>(key: &'a Key, destination: &'a Path, require_ownershi } pub async fn feed_uploader(mut uploader: Child, key: &Key, job: Option) -> ColmenaResult<()> { - let mut reader = key.reader().await?; + let mut reader = key.reader().await + .map_err(|error| ColmenaError::KeyError { + name: key.name().to_owned(), + error, + })?; let mut stdin = uploader.stdin.take().unwrap(); tokio::io::copy(reader.as_mut(), &mut stdin).await?; diff --git a/src/nix/key.rs b/src/nix/key.rs index 3dc6953..7bede72 100644 --- a/src/nix/key.rs +++ b/src/nix/key.rs @@ -148,6 +148,7 @@ impl Key { } } + pub fn name(&self) -> &str { &self.name } pub fn path(&self) -> &Path { &self.path } pub fn user(&self) -> &str { &self.user } pub fn group(&self) -> &str { &self.group }