-use std::io::Result;
+use std::io::{Error, ErrorKind::Other, Result};
use crate::configuration::Configuration;
use std::process::{Command, Stdio};
fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
- let input = input.expect("You must provide a location to publish the blog");
+ let input = input
+ .ok_or_else(|| Error::new(Other, "You must provide a location to publish the blog"))?;
Command::new(COMMAND)
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
- .expect("Publishing requires rsync");
+ .map_err(|_| Error::new(Other, "Publishing requires rsync"))?;
Command::new(COMMAND)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
- .expect("Publishing requires rsync");
+ .map_err(|_| Error::new(Other, "Rsync failed to publish."))?;
return Ok(())
}