From acf7ef28ab994e6063a81c08e1d1f2dbf876a71a Mon Sep 17 00:00:00 2001 From: Kevin Yue Date: Wed, 30 Aug 2023 13:35:17 +0800 Subject: [PATCH] refactor: improve the error message --- gpgui/src-tauri/src/storage.rs | 5 ++++- gpgui/src/components/ConnectForm/PasswordAuth.tsx | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gpgui/src-tauri/src/storage.rs b/gpgui/src-tauri/src/storage.rs index 6a6847d..6770362 100644 --- a/gpgui/src-tauri/src/storage.rs +++ b/gpgui/src-tauri/src/storage.rs @@ -32,12 +32,15 @@ impl AppStorage<'_> { } } + /// Get a value from the store (.data.json). + /// If the value is encrypted, it will be decrypted. + /// If the value is not found, or if there is an error, `None` is returned. pub fn get(&self, hint: KeyHint) -> Option { let stores = self.app_handle.state::>(); with_store(self.app_handle.clone(), stores, self.path, |store| { store .get(hint.key) - .ok_or_else(|| Error::Deserialize("Value not found".into())) + .ok_or_else(|| Error::Deserialize(format!("Key {} not found in store", hint.key).into())) .and_then(|value| { if !hint.encrypted { return Ok(serde_json::from_value::(value.clone())?); diff --git a/gpgui/src/components/ConnectForm/PasswordAuth.tsx b/gpgui/src/components/ConnectForm/PasswordAuth.tsx index a66892e..e9f3a22 100644 --- a/gpgui/src/components/ConnectForm/PasswordAuth.tsx +++ b/gpgui/src/components/ConnectForm/PasswordAuth.tsx @@ -66,6 +66,7 @@ export default function PasswordAuth() { type="submit" loading={loading} disabled={loading} + sx={{ flex: 1 }} > Login