summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mullvad-cli/src/cmds/reset.rs13
-rw-r--r--mullvad-daemon/src/lib.rs20
2 files changed, 22 insertions, 11 deletions
diff --git a/mullvad-cli/src/cmds/reset.rs b/mullvad-cli/src/cmds/reset.rs
index bb10a3f0fe..1be34a0ab0 100644
--- a/mullvad-cli/src/cmds/reset.rs
+++ b/mullvad-cli/src/cmds/reset.rs
@@ -1,4 +1,4 @@
-use crate::{new_rpc_client, Command, Result};
+use crate::{new_rpc_client, Command, Error, Result};
use std::io::stdin;
pub struct Reset;
@@ -15,12 +15,11 @@ impl Command for Reset {
async fn run(&self, _: &clap::ArgMatches<'_>) -> Result<()> {
let mut rpc = new_rpc_client().await?;
if Self::receive_confirmation() {
- if rpc.factory_reset(()).await.is_err() {
- eprintln!("FAILED TO PERFORM FACTORY RESET");
- } else {
- #[cfg(target_os = "linux")]
- println!("If you're running systemd, to remove all logs, you must use journalctl");
- }
+ rpc.factory_reset(())
+ .await
+ .map_err(|error| Error::RpcFailedExt("FAILED TO PERFORM FACTORY RESET", error))?;
+ #[cfg(target_os = "linux")]
+ println!("If you're running systemd, to remove all logs, you must use journalctl");
}
Ok(())
}
diff --git a/mullvad-daemon/src/lib.rs b/mullvad-daemon/src/lib.rs
index 754f6d34f7..691e96cd5b 100644
--- a/mullvad-daemon/src/lib.rs
+++ b/mullvad-daemon/src/lib.rs
@@ -124,6 +124,18 @@ pub enum Error {
#[error(display = "Account history error")]
AccountHistory(#[error(source)] account_history::Error),
+ #[error(display = "Failed to clear cache directory")]
+ ClearCacheError,
+
+ #[error(display = "Failed to clear logs directory")]
+ ClearLogsError,
+
+ #[error(display = "Failed to clear account history")]
+ ClearAccountHistoryError(#[error(source)] account_history::Error),
+
+ #[error(display = "Failed to clear settings")]
+ ClearSettingsError(#[error(source)] settings::Error),
+
#[error(display = "Tunnel state machine error")]
TunnelError(#[error(source)] tunnel_state_machine::Error),
@@ -1541,12 +1553,12 @@ where
if let Err(e) = self.settings.reset() {
log::error!("Failed to reset settings - {}", e);
- last_error = Err(Error::SettingsError(e));
+ last_error = Err(Error::ClearSettingsError(e));
}
if let Err(e) = self.account_history.clear().await {
log::error!("Failed to clear account history - {}", e);
- last_error = Err(Error::AccountHistory(e));
+ last_error = Err(Error::ClearAccountHistoryError(e));
}
// Shut the daemon down.
@@ -1558,7 +1570,7 @@ where
"{}",
e.display_chain_with_msg("Failed to clear cache directory")
);
- last_error = Err(e);
+ last_error = Err(Error::ClearCacheError);
}
if let Err(e) = Self::clear_log_directory() {
@@ -1566,7 +1578,7 @@ where
"{}",
e.display_chain_with_msg("Failed to clear log directory")
);
- last_error = Err(e);
+ last_error = Err(Error::ClearLogsError);
}
Self::oneshot_send(tx, last_error, "factory_reset response");
}));