Skip to content

Commit

Permalink
feat(console): only suggest opening issues for panics (#365)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
hawkw committed Aug 5, 2022
1 parent 40e2f6f commit 23cb6bf
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tokio-console/src/view/styles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 23cb6bf

Please sign in to comment.