]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/update.rs
Improve the error handling
[rbdr/blog] / src / command / update.rs
index 67cc462c110b32da48f064d045ab756a23c48fda..8a3d6de47e27e41d53d66b6b13344fc6ee2e5832 100644 (file)
@@ -55,7 +55,8 @@ impl super::Command for Update {
     }
 
     fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> {
-        let input = input.expect("You must provide a path to a post");
+        let input = input
+            .ok_or_else(|| Error::new(ErrorKind::InvalidInput, "You must provide a path to a post"))?;
         let post_location = PathBuf::from(input);
         if !post_location.exists() {
             return Err(Error::new(ErrorKind::NotFound, "The path provided does not exist"));