summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src
diff options
context:
space:
mode:
authorTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-09-01 10:57:05 +0200
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-09-30 09:51:49 +0200
commitec037d64d7f79321ea115eaa3a593f7d160721f6 (patch)
tree07d6b2cc960c0f61b00137b8036628f9d4f89581 /mullvad-daemon/src
parent970c3cb692eef2a25a08573cd89f143040006e7f (diff)
downloadmullvadvpn-ec037d64d7f79321ea115eaa3a593f7d160721f6.tar.xz
mullvadvpn-ec037d64d7f79321ea115eaa3a593f7d160721f6.zip
Handle error returned by access method's update function
Map error in settings::Error in the update_access_method fn so we can use the From impl to turn the error into a management interface status later.
Diffstat (limited to 'mullvad-daemon/src')
-rw-r--r--mullvad-daemon/src/access_method.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/mullvad-daemon/src/access_method.rs b/mullvad-daemon/src/access_method.rs
index 731018175d..3e3811fb83 100644
--- a/mullvad-daemon/src/access_method.rs
+++ b/mullvad-daemon/src/access_method.rs
@@ -81,11 +81,12 @@ impl Daemon {
access_method: access_method::Id,
) -> Result<(), Error> {
self.settings
- .update(|settings| {
+ .try_update(|settings| -> Result<(), Error> {
settings.api_access_methods.update(
|setting| setting.get_id() == access_method,
|setting| setting.enable(),
- );
+ )?;
+ Ok(())
})
.await?;
self.access_mode_handler
@@ -112,16 +113,20 @@ impl Daemon {
pub async fn update_access_method(
&mut self,
access_method_update: AccessMethodSetting,
- ) -> Result<(), Error> {
+ ) -> Result<(), crate::Error> {
self.settings
- .update(|settings: &mut Settings| {
- let target = access_method_update.get_id();
- settings.api_access_methods.update(
- |access_method| access_method.get_id() == target,
- |method| *method = access_method_update,
- );
- })
- .await?;
+ .try_update(
+ |settings: &mut Settings| -> Result<(), access_method::Error> {
+ let target = access_method_update.get_id();
+ settings.api_access_methods.update(
+ |access_method| access_method.get_id() == target,
+ |method| *method = access_method_update,
+ )?;
+ Ok(())
+ },
+ )
+ .await
+ .map_err(crate::Error::SettingsError)?;
Ok(())
}