1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 05:10:03 -04:00

Log warning instead of error when failing to decode RON in storage (#2961)

* Log warning instead of error when failing to decode RON in storage

* New web demo

* Clean up some warn/error logging

* Avoid deadlock that could happen on crash

* Log errors using console.warn, because console.error can cause crashes

* Use patched version of wasm-bindgen-cli, allowing >2GB memory

* New web demo
This commit is contained in:
Emil Ernerfeldt
2023-04-27 09:45:44 +02:00
committed by GitHub
parent f76eefb98d
commit 3d6a15f442
10 changed files with 41 additions and 29 deletions

View File

@@ -1051,7 +1051,13 @@ impl Storage for DummyStorage {
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
storage
.get_string(key)
.and_then(|value| ron::from_str(&value).ok())
.and_then(|value| match ron::from_str(&value) {
Ok(value) => Some(value),
Err(err) => {
log::warn!("Failed to decode RON: {err}");
None
}
})
}
/// Serialize the given value as [RON](https://github.com/ron-rs/ron) and store with the given key.