From 65948b00b4aa1411491096d0a429c67df01acdea Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Wed, 23 Aug 2023 11:01:16 -0400 Subject: [PATCH] Manually catch & print errors in main() This lets us ensure that we see the Display impls intead of the Debug impls, which are generally less useful. --- fontc/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fontc/src/main.rs b/fontc/src/main.rs index 9f88be8b..a28e69c0 100644 --- a/fontc/src/main.rs +++ b/fontc/src/main.rs @@ -6,7 +6,16 @@ use fontbe::orchestration::Context as BeContext; use fontc::{init_paths, write_font_file, Args, ChangeDetector, Config, Error}; use fontir::orchestration::Context as FeContext; -fn main() -> Result<(), Error> { +fn main() { + // catch and print errors manually, to avoid just seeing the Debug impls + if let Err(e) = run() { + // we have a CI check that forbids eprintln, but we're very clever, so + let _ = writeln!(std::io::stderr(), "{e}"); + std::process::exit(1); + } +} + +fn run() -> Result<(), Error> { env_logger::builder() .format(|buf, record| { let ts = buf.timestamp_micros();