From 087580b3c269dbc5b2298ff6f4590f010279d339 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 20 Dec 2019 17:04:45 +0100 Subject: don't error when cache value can't be deserialized The cache is meant to help out by saving old responses. If those responses do not conform anymore to an updated struct definition, the whole application should not crash. Instead, the value is silently ignored and then overwritten by the proper value that has been fetched from the API. That way, users don't have to manually clear out the cache if a new API schema or new features are released. --- src/api/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/api/mod.rs b/src/api/mod.rs index 27f0da1..ffed5ea 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -123,7 +123,7 @@ impl Api { P: AsRef, { match self.cache.get(name.as_ref())? { - Some(data) => Ok(serde_json::from_slice(&data)?), + Some(data) => serde_json::from_slice(&data).or(Ok(None)), None => Ok(None), } } -- cgit v1.2.3