From 50f53dc480fda8b3daab7a34454c2dd9f3f5f991 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sat, 9 Mar 2024 15:34:57 +0100 Subject: Improve the error handling --- src/command/add_remote.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/command/add_remote.rs') diff --git a/src/command/add_remote.rs b/src/command/add_remote.rs index 040e572..e9157f3 100644 --- a/src/command/add_remote.rs +++ b/src/command/add_remote.rs @@ -1,4 +1,4 @@ -use std::io::Result; +use std::io::{Error, ErrorKind::Other, Result}; use crate::configuration::Configuration; use crate::remote::add; @@ -16,7 +16,8 @@ impl super::Command for AddRemote { } fn execute(&self, input: Option<&String>, configuration: &Configuration, _: &String) -> Result<()> { - let input = input.expect("You must provide a location for the remote."); + let input = input + .ok_or_else(|| Error::new(Other, "You must provide a location for the remote."))?; add(&configuration.config_directory, &configuration.remote_config, input) } -- cgit