diff options
| author | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-09 15:34:57 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <git@r.bdr.sh> | 2024-03-09 15:34:57 +0100 |
| commit | 50f53dc480fda8b3daab7a34454c2dd9f3f5f991 (patch) | |
| tree | 2205be7a9c806ce59c851de9b50b9e18f973008d /src/command/publish_archive.rs | |
| parent | 172f4c8807d44ebe38c7f227b7fdc2d6a9dbe323 (diff) | |
Improve the error handlingrust
Diffstat (limited to 'src/command/publish_archive.rs')
| -rw-r--r-- | src/command/publish_archive.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/command/publish_archive.rs b/src/command/publish_archive.rs index 075421f..c727c16 100644 --- a/src/command/publish_archive.rs +++ b/src/command/publish_archive.rs @@ -1,4 +1,4 @@ -use std::io::Result; +use std::io::{Error, ErrorKind::Other, Result}; 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<()> { - 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() - .expect("Publishing requires rsync"); + .map_err(|_| Error::new(Other, "Publishing requires rsync"))?; Command::new(COMMAND) @@ -36,7 +37,7 @@ impl super::Command for PublishArchive { .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .expect("Publishing requires rsync"); + .map_err(|_| Error::new(Other, "Rsync failed to publish."))?; return Ok(()) } |