aboutsummaryrefslogtreecommitdiff
path: root/src/remote/mod.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 15:34:57 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 15:34:57 +0100
commit50f53dc480fda8b3daab7a34454c2dd9f3f5f991 (patch)
tree2205be7a9c806ce59c851de9b50b9e18f973008d /src/remote/mod.rs
parent172f4c8807d44ebe38c7f227b7fdc2d6a9dbe323 (diff)
Improve the error handlingrust
Diffstat (limited to 'src/remote/mod.rs')
-rw-r--r--src/remote/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/remote/mod.rs b/src/remote/mod.rs
index de90ef5..19514af 100644
--- a/src/remote/mod.rs
+++ b/src/remote/mod.rs
@@ -27,7 +27,7 @@ pub fn remove(remote_config: &PathBuf) -> Result<()> {
pub fn sync_up(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()> {
let remote_address = read_remote(remote_config)
- .expect("No remote is configured");
+ .ok_or_else(|| Error::new(Other, "No remote is configured"))?;
create_dir_all(data_directory)?;
let remotes = available_remotes();
for remote in remotes {
@@ -40,7 +40,7 @@ pub fn sync_up(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()>
pub fn sync_down(data_directory: &PathBuf, remote_config: &PathBuf) -> Result<()> {
let remote_address = read_remote(remote_config)
- .expect("No remote is configured");
+ .ok_or_else(|| Error::new(Other, "No remote is configured"))?;
create_dir_all(data_directory)?;
let remotes = available_remotes();
for remote in remotes {