summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-04-30 15:20:00 +0200
committersharkdp <davidpeter@web.de>2018-04-30 15:20:00 +0200
commitced68017408972ba613854d8002d38934f0918e4 (patch)
tree2ed6040fa36edeee3a655047848725de8c321d09
parentf81e38618ccaf7c3c7b0ef953d2f472695e01ade (diff)
Better error messages
-rw-r--r--Cargo.toml2
-rw-r--r--README.md2
-rw-r--r--src/main.rs18
3 files changed, 17 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index caaf71c1..c2f764c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ lazy_static = "1.0"
[dependencies.syntect]
version = "2"
default-features = false
-features = ["parsing", "yaml-load", "dump-load", "assets", "dump-create"]
+features = ["parsing", "yaml-load", "dump-load", "dump-create"]
[dependencies.clap]
version = "2"
diff --git a/README.md b/README.md
index 47523082..743e501f 100644
--- a/README.md
+++ b/README.md
@@ -47,4 +47,6 @@ cd ~/.config/bat/syntax
git clone https://github.com/sublimehq/Packages/
rm -rf Packages/Markdown
git clone https://github.com/jonschlinkert/sublime-markdown-extended
+
+bat init-cache
```
diff --git a/src/main.rs b/src/main.rs
index f6b9a269..268c27a9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -283,20 +283,30 @@ impl HighlightingAssets {
let theme_set_path = cache_dir.join("theme_set");
let syntax_set_path = cache_dir.join("syntax_set");
- let syntax_set_file = File::open(syntax_set_path)?;
+ let syntax_set_file = File::open(&syntax_set_path).chain_err(|| {
+ format!(
+ "Could not load cached syntax set '{}'",
+ syntax_set_path.to_string_lossy()
+ )
+ })?;
let mut syntax_set: SyntaxSet = from_reader(syntax_set_file).map_err(|_| {
io::Error::new(
io::ErrorKind::Other,
- format!("Could not load cached syntax set"),
+ format!("Could not parse cached syntax set"),
)
})?;
syntax_set.link_syntaxes();
- let theme_set_file = File::open(theme_set_path)?;
+ let theme_set_file = File::open(&theme_set_path).chain_err(|| {
+ format!(
+ "Could not load cached theme set '{}'",
+ theme_set_path.to_string_lossy()
+ )
+ })?;
let theme_set: ThemeSet = from_reader(theme_set_file).map_err(|_| {
io::Error::new(
io::ErrorKind::Other,
- format!("Could not load cached theme set"),
+ format!("Could not parse cached theme set"),
)
})?;