diff --git a/acmed/src/acmed.rs b/acmed/src/acmed.rs index 0ed45a6..6709dcf 100644 --- a/acmed/src/acmed.rs +++ b/acmed/src/acmed.rs @@ -138,8 +138,8 @@ impl HookData { .spawn()?; if hook.stdin.is_some() { let data_in = reg.render_template(&hook.stdin.to_owned().unwrap(), &self)?; - let stdin = cmd.stdin.as_mut().unwrap(); - stdin.write_all(data_in.as_bytes()).unwrap(); + let stdin = cmd.stdin.as_mut().ok_or("stdin not found")?; + stdin.write_all(data_in.as_bytes())?; } Ok(()) } diff --git a/acmed/src/errors.rs b/acmed/src/errors.rs index 30042a8..1aa679e 100644 --- a/acmed/src/errors.rs +++ b/acmed/src/errors.rs @@ -24,6 +24,12 @@ impl From for Error { } } +impl From<&str> for Error { + fn from(error: &str) -> Self { + Error::new(error) + } +} + impl From for Error { fn from(error: toml::de::Error) -> Self { Error::new(&format!("IO error: {}", error))