diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-02 07:29:10 +0200 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-09-30 09:51:49 +0200 |
| commit | eccd02165200e8f44221332c8ffc7b6c8654d52d (patch) | |
| tree | 84333f55b3a4bf797e499e9a8be97980d9348285 | |
| parent | f75754efd2b5ffd2038103cdf0898f00c084d00b (diff) | |
| download | mullvadvpn-eccd02165200e8f44221332c8ffc7b6c8654d52d.tar.xz mullvadvpn-eccd02165200e8f44221332c8ffc7b6c8654d52d.zip | |
Refactor map_custom_list_error to reduce duplication
| -rw-r--r-- | mullvad-management-interface/src/client.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/mullvad-management-interface/src/client.rs b/mullvad-management-interface/src/client.rs index 8f85266f26..933768f5f5 100644 --- a/mullvad-management-interface/src/client.rs +++ b/mullvad-management-interface/src/client.rs @@ -654,21 +654,11 @@ fn map_device_error(status: Status) -> Error { #[cfg(not(target_os = "android"))] fn map_custom_list_error(status: Status) -> Error { - match status.code() { - Code::NotFound => { - if status.details() == crate::CUSTOM_LIST_LIST_NOT_FOUND_DETAILS { - Error::CustomListListNotFound - } else { - Error::Rpc(Box::new(status)) - } - } - Code::AlreadyExists => { - if status.details() == crate::CUSTOM_LIST_LIST_EXISTS_DETAILS { - Error::CustomListExists - } else { - Error::Rpc(Box::new(status)) - } + match (status.code(), status.details()) { + (Code::NotFound, crate::CUSTOM_LIST_LIST_NOT_FOUND_DETAILS) => { + Error::CustomListListNotFound } + (Code::AlreadyExists, crate::CUSTOM_LIST_LIST_EXISTS_DETAILS) => Error::CustomListExists, _other => Error::Rpc(Box::new(status)), } } |
