From 9b082edb8d0703755b441d841ff25f708f4d8a8a Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 15 May 2021 13:39:31 -0700 Subject: [PATCH] log errors when a color scheme fails to load refs: https://github.com/wez/wezterm/issues/794 --- config/src/lib.rs | 29 ++++++++++++++++++----------- docs/changelog.md | 1 + 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/config/src/lib.rs b/config/src/lib.rs index 236514cc0..48a113711 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -1578,9 +1578,7 @@ impl Config { fn load_scheme(path: &Path) -> Result { let s = std::fs::read_to_string(path)?; - let scheme: ColorSchemeFile = toml::from_str(&s).with_context(|| { - format!("Error parsing color scheme TOML from {}", path.display()) - })?; + let scheme: ColorSchemeFile = toml::from_str(&s).context("parsing TOML")?; Ok(scheme) } @@ -1596,14 +1594,23 @@ impl Config { } let path = entry.path(); - if let Ok(scheme) = load_scheme(&path) { - log::trace!( - "Loaded color scheme `{}` from {}", - scheme_name, - path.display() - ); - self.color_schemes - .insert(scheme_name.to_string(), scheme.colors); + match load_scheme(&path) { + Ok(scheme) => { + log::trace!( + "Loaded color scheme `{}` from {}", + scheme_name, + path.display() + ); + self.color_schemes + .insert(scheme_name.to_string(), scheme.colors); + } + Err(err) => { + log::error!( + "Color scheme in `{}` failed to load: {:#}", + path.display(), + err + ); + } } } } diff --git a/docs/changelog.md b/docs/changelog.md index 84ce39f33..e399ff92e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -21,6 +21,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: we now recognize the `CSI 48:2:0:214:255m` form of specifying true color text attributes [#785](https://github.com/wez/wezterm/issues/785) * Fixed: split separators didn't respect `tab_bar_at_bottom=true` and were rendered in the wrong place [#797](https://github.com/wez/wezterm/issues/797) * Improved: messaging around [exit_behavior](https://wezfurlong.org/wezterm/config/lua/config/exit_behavior.html) +* Fixed: errors loading custom color schemes are now logged to the error log [#794](https://github.com/wez/wezterm/issues/794) ### 20210502-154244-3f7122cb