summaryrefslogtreecommitdiff
path: root/src/bin/subplot.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-08-13 19:03:37 +0300
committerLars Wirzenius <liw@liw.fi>2022-08-13 19:03:37 +0300
commit9b3b0087512614d13e8c3b950041101ab649b786 (patch)
tree8dbf69f30988038b9907cd2462790ee2d3790fb3 /src/bin/subplot.rs
parent60b5a9a313bec0a6e475f9c16380977ed1c7eafb (diff)
downloadsubplot-9b3b0087512614d13e8c3b950041101ab649b786.tar.gz
feat: make errors have a source error
When errors have a source, i.e., an underlying error, it results in better error messages to the user. Also, refactor the way the source chain is printed, to code that is clearer to me. I will need this to for loading document metadata from an external YAML file. Sponsored-by: author
Diffstat (limited to 'src/bin/subplot.rs')
-rw-r--r--src/bin/subplot.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs
index e9cb00a..5e802b4 100644
--- a/src/bin/subplot.rs
+++ b/src/bin/subplot.rs
@@ -504,13 +504,6 @@ fn load_linted_doc(
Ok(doc)
}
-fn print_source_errors(e: Option<&dyn std::error::Error>) {
- if let Some(e) = e {
- error!("{}", e);
- print_source_errors(e.source());
- }
-}
-
fn real_main() {
info!("Starting Subplot");
let argparser = Toplevel::command();
@@ -525,7 +518,11 @@ fn real_main() {
}
Err(e) => {
error!("{}", e);
- print_source_errors(e.source());
+ let mut e = e.source();
+ while let Some(source) = e {
+ error!("caused by: {}", source);
+ e = source.source();
+ }
process::exit(1);
}
}