Indicate the key-path to the error when failing to load a theme

This commit is contained in:
Max Brunsfeld 2021-08-26 15:02:58 -07:00
parent 3bb5610ad1
commit 8c85bc20c7
3 changed files with 5 additions and 4 deletions

1
Cargo.lock generated
View file

@ -5835,6 +5835,7 @@ dependencies = [
"seahash", "seahash",
"serde 1.0.125", "serde 1.0.125",
"serde_json 1.0.64", "serde_json 1.0.64",
"serde_path_to_error",
"similar", "similar",
"simplelog", "simplelog",
"smallvec", "smallvec",

View file

@ -42,6 +42,7 @@ rust-embed = "5.9.0"
seahash = "4.1" seahash = "4.1"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = { version = "1.0.64", features = ["preserve_order"] } serde_json = { version = "1.0.64", features = ["preserve_order"] }
serde_path_to_error = "0.1.4"
similar = "1.3" similar = "1.3"
simplelog = "0.9" simplelog = "0.9"
smallvec = { version = "1.6", features = ["union"] } smallvec = { version = "1.6", features = ["union"] }

View file

@ -1,8 +1,7 @@
use anyhow::{anyhow, Context, Result}; use anyhow::{anyhow, Context, Result};
use gpui::{fonts, AssetSource, FontCache}; use gpui::{fonts, AssetSource, FontCache};
use json::{Map, Value};
use parking_lot::Mutex; use parking_lot::Mutex;
use serde_json as json; use serde_json::{Map, Value};
use std::{collections::HashMap, fmt, mem, sync::Arc}; use std::{collections::HashMap, fmt, mem, sync::Arc};
use super::Theme; use super::Theme;
@ -71,8 +70,8 @@ impl ThemeRegistry {
} }
let theme_data = self.load(name, true)?; let theme_data = self.load(name, true)?;
let mut theme = fonts::with_font_cache(self.font_cache.clone(), || { let mut theme: Theme = fonts::with_font_cache(self.font_cache.clone(), || {
serde_json::from_value::<Theme>(theme_data.as_ref().clone()) serde_path_to_error::deserialize(theme_data.as_ref())
})?; })?;
theme.name = name.into(); theme.name = name.into();