mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
refactor: improve the error message
This commit is contained in:
parent
11a374765c
commit
acf7ef28ab
@ -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<T: DeserializeOwned + Debug>(&self, hint: KeyHint) -> Option<T> {
|
||||
let stores = self.app_handle.state::<StoreCollection<Wry>>();
|
||||
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::<T>(value.clone())?);
|
||||
|
@ -66,6 +66,7 @@ export default function PasswordAuth() {
|
||||
type="submit"
|
||||
loading={loading}
|
||||
disabled={loading}
|
||||
sx={{ flex: 1 }}
|
||||
>
|
||||
Login
|
||||
</LoadingButton>
|
||||
|
Loading…
Reference in New Issue
Block a user