From 8a81f0549278d9c9b3b7b1709776b229b8945111 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 16:16:52 +0000 Subject: [PATCH] fix(cli): print clean error chain instead of anyhow Debug with backtrace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When RUST_BACKTRACE was set in the environment, every user-facing error dumped a 20-line Rust backtrace at the user — e.g. running 'onyx list show' with no workspace gave them a stack trace through anyhow, clap, and libc start. Replace 'fn main() -> Result' with an explicit error printer that walks the anyhow cause chain using Display, and exits 1. Programming-bug panics still surface through the default panic handler. --- crates/onyx-cli/src/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/onyx-cli/src/main.rs b/crates/onyx-cli/src/main.rs index ebaae18..76518af 100644 --- a/crates/onyx-cli/src/main.rs +++ b/crates/onyx-cli/src/main.rs @@ -3,6 +3,7 @@ mod output; use anyhow::Result; use clap::{Parser, Subcommand}; +use colored::Colorize; use commands::*; #[derive(Parser)] @@ -197,7 +198,24 @@ enum GroupCommands { }, } -fn main() -> Result<()> { +fn main() { + match run() { + Ok(()) => {} + Err(e) => { + // Print user-friendly error chain (no backtrace). Programming-bug + // panics still surface through their default handler. + eprintln!("{}: {}", "Error".red().bold(), e); + let mut cause = e.source(); + while let Some(c) = cause { + eprintln!(" caused by: {}", c); + cause = c.source(); + } + std::process::exit(1); + } + } +} + +fn run() -> Result<()> { let cli = Cli::parse(); match cli.command {