aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-02-19 05:45:22 +0000
committerBlaž Hrastnik2022-03-10 08:31:57 +0000
commit31b7596f093c313bc88867f3ba2ae9813f7c55d4 (patch)
tree414f9f88b7c611f7a254553ce8c7adfddecb7a86
parent4fc991fdeca5db36bd7be7197510e62a019e1677 (diff)
fix context in error
-rw-r--r--helix-loader/src/grammar.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/helix-loader/src/grammar.rs b/helix-loader/src/grammar.rs
index 61ef464f..4fe7fd04 100644
--- a/helix-loader/src/grammar.rs
+++ b/helix-loader/src/grammar.rs
@@ -123,18 +123,14 @@ where
tx.send(job(grammar)).unwrap();
});
}
- pool.join();
+
+ drop(tx);
// TODO: print all failures instead of the first one found.
- if let Some(failure) = rx.try_iter().find_map(|result| result.err()) {
- Err(anyhow!(
- "Failed to {} some grammar(s).\n{}",
- action,
- failure
- ))
- } else {
- Ok(())
- }
+ rx.iter()
+ .find(|result| result.is_err())
+ .map(|err| err.with_context(|| format!("Failed to {} some grammar(s)", action)))
+ .unwrap_or(Ok(()))
}
fn fetch_grammar(grammar: GrammarConfiguration) -> Result<()> {