]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/publish_archive.rs
Manually import
[rbdr/blog] / src / command / publish_archive.rs
index 075421f0ac1b25c1f2738724f656832af6692363..c727c16bc87c72377286da92323a50e94e9bb445 100644 (file)
@@ -1,4 +1,4 @@
-use std::io::Result;
+use std::io::{Error, ErrorKind::Other, Result};
 use crate::configuration::Configuration;
 use std::process::{Command, Stdio};
 
 use crate::configuration::Configuration;
 use std::process::{Command, Stdio};
 
@@ -19,14 +19,15 @@ impl super::Command for PublishArchive {
 
     fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
 
 
     fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
 
-        let input = input.expect("You must provide a location to publish the archive");
+        let input = input
+            .ok_or_else(|| Error::new(Other, "You must provide a location to publish the archive"))?;
 
         Command::new(COMMAND)
             .arg("--version")
             .stdout(Stdio::null())
             .stderr(Stdio::null())
             .status()
 
         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)
 
 
         Command::new(COMMAND)
@@ -36,7 +37,7 @@ impl super::Command for PublishArchive {
             .stdout(Stdio::null())
             .stderr(Stdio::null())
             .status()
             .stdout(Stdio::null())
             .stderr(Stdio::null())
             .status()
-            .expect("Publishing requires rsync");
+            .map_err(|_| Error::new(Other, "Rsync failed to publish."))?;
         return Ok(())
     }
 
         return Ok(())
     }