From da2a89c0481277be78034e3c60c978d7a7a0f59b Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 5 Aug 2022 12:45:51 -0700 Subject: [PATCH] feat(console): only suggest opening issues for panics (#365) This changes the console CLI's error handling so that GitHub issues are only suggested for panics, not for recoverable errors (such as "no config file found", "couldn't connect to remote host", etc). --- tokio-console/src/view/styles.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tokio-console/src/view/styles.rs b/tokio-console/src/view/styles.rs index 515308441..dbcd6f06a 100644 --- a/tokio-console/src/view/styles.rs +++ b/tokio-console/src/view/styles.rs @@ -48,11 +48,23 @@ impl Styles { } pub fn error_init(&self) -> color_eyre::Result<()> { - use color_eyre::config::{HookBuilder, Theme}; + use color_eyre::{ + config::{HookBuilder, Theme}, + ErrorKind, + }; let mut builder = HookBuilder::new() .issue_url(concat!(env!("CARGO_PKG_REPOSITORY"), "/issues/new")) - .add_issue_metadata("version", env!("CARGO_PKG_VERSION")); + .add_issue_metadata("version", env!("CARGO_PKG_VERSION")) + .issue_filter(|kind| match kind { + // Only suggest reporting GitHub issues for panics, not for + // errors, so people don't open GitHub issues for stuff like not + // being able to find a config file or connections being + // terminated by remote hosts. + ErrorKind::NonRecoverable(_) => true, + ErrorKind::Recoverable(_) => false, + }); + if self.palette == Palette::NoColors { // disable colors in error reports builder = builder.theme(Theme::new());