on master help sign in
bat cache --build: Print syntect error message for themes if any

This will fix #614 by making it clear what is wrong by showing the following error message: Failed to load one or more themes from '/Users/me/.config/bat/themes' (reason: 'Invalid syntax theme settings') We also need to add a check if theme_dir.exists(), otherwise an absent dir will seem like an error: Failed to load one or more themes from '/Users/me/.config/bat/themes' (reason: 'IO error for operation on /Users/me/.config/bat/themes: No such file or directory (os error 2)') (This is the same check we already have for syntax_dir.)

commit05e9da390fbb9a595b15df4860f61efde81ea9d2 authorMartin Nordholts <enselic@gmail.com> dateMon 28 Dec 2020, 10:34 (6 years ago) parent9c16571
1 file changed+10−3
src/assets.rs+10−3
src/assets.rs+10−3
@@ -38,9 +38,16 @@ impl HighlightingAssets {
3838 };
3939
4040 let theme_dir = source_dir.join("themes");
41−
42− let res = theme_set.add_from_folder(&theme_dir);
43− if res.is_err() {
41+ if theme_dir.exists() {
42+ let res = theme_set.add_from_folder(&theme_dir);
43+ if let Err(err) = res {
44+ println!(
45+ "Failed to load one or more themes from '{}' (reason: '{}')",
46+ theme_dir.to_string_lossy(),
47+ err,
48+ );
49+ }
50+ } else {
4451 println!(
4552 "No themes were found in '{}', using the default set",
4653 theme_dir.to_string_lossy()