Add wrapper error telling the user to file an issue

This commit is contained in:
Csonka Mihaly 2020-03-22 23:32:03 +01:00
parent a625b0aea0
commit 4bc9b00a52
4 changed files with 24 additions and 3 deletions

View file

@ -1,7 +1,7 @@
extern crate navi;
use anyhow::Error;
use navi::FileAnIssue;
fn main() -> Result<(), Error> {
navi::handle_config(navi::config_from_env())
fn main() -> Result<(), FileAnIssue> {
navi::handle_config(navi::config_from_env()).map_err(FileAnIssue::new)
}

View file

@ -15,4 +15,5 @@ mod terminal;
mod welcome;
pub use handler::handle_config;
pub use structures::error::file_issue::FileAnIssue;
pub use structures::option::{config_from_env, config_from_iter};

View file

@ -0,0 +1,19 @@
use std::fmt::Debug;
use thiserror::Error;
#[derive(Error, Debug)]
#[error(
"Hey listen! Navi encountered a problem.
Do you think this is a bug? File an issue at https://github.com/denisidoro/navi."
)]
pub struct FileAnIssue(#[source] anyhow::Error);
impl FileAnIssue {
pub fn new<SourceError>(source: SourceError) -> Self
where
SourceError: Into<anyhow::Error>,
{
FileAnIssue(source.into())
}
}

View file

@ -1,2 +1,3 @@
pub mod command;
pub mod file_issue;
pub mod filesystem;