on master help sign in
Improve error message handling for theme loading failures (#5073)
db93980Michael Davis
helix-term/src/commands/typed.rs+1−1
@@ -777,7 +777,7 @@ fn theme(
777 .editor
777 .editor
778 .theme_loader
778 .theme_loader
779 .load(theme_name)
779 .load(theme_name)
780− .with_context(|| "Theme does not exist")?;
780+ .map_err(|err| anyhow::anyhow!("Could not load theme: {}", err))?;
781 if !(true_color || theme.is_16_color()) {
781 if !(true_color || theme.is_16_color()) {
782 bail!("Unsupported theme: theme requires true color support");
782 bail!("Unsupported theme: theme requires true color support");
783 }
783 }
helix-view/src/theme.rs+2−1
@@ -136,8 +136,9 @@ impl Loader {
136 // Loads the theme data as `toml::Value` first from the user_dir then in default_dir
136 // Loads the theme data as `toml::Value` first from the user_dir then in default_dir
137 fn load_toml(&self, path: PathBuf) -> Result<Value> {
137 fn load_toml(&self, path: PathBuf) -> Result<Value> {
138 let data = std::fs::read(&path)?;
138 let data = std::fs::read(&path)?;
139+ let value = toml::from_slice(data.as_slice())?;
139
140
140− toml::from_slice(data.as_slice()).context("Failed to deserialize theme")
141+ Ok(value)
141 }
142 }
142
143
143 // Returns the path to the theme with the name
144 // Returns the path to the theme with the name