From 95b3ec7c766e2a92cc85c25449565554e3bcde02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 13 Mar 2024 14:08:47 +0100 Subject: [PATCH] Disable stack traces for normal errors in release mode --- crates/hyperqueue/src/bin/hq.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/hyperqueue/src/bin/hq.rs b/crates/hyperqueue/src/bin/hq.rs index 77c8879f0..05c63ca74 100644 --- a/crates/hyperqueue/src/bin/hq.rs +++ b/crates/hyperqueue/src/bin/hq.rs @@ -362,8 +362,16 @@ async fn main() -> hyperqueue::Result<()> { })); // Also enable backtraces by default. + // This enables backtraces when panicking, but also for normal anyhow errors. std::env::set_var("RUST_BACKTRACE", "full"); + // This further disables backtraces for normal anyhow errors. + // They should not be printed to users in release mode. + #[cfg(not(debug_assertions))] + { + std::env::set_var("RUST_LIB_BACKTRACE", "0"); + } + let matches = RootOptions::command().get_matches(); let top_opts = match RootOptions::from_arg_matches(&matches) { Ok(opts) => opts,