Reset ansi more often when showing errors (#425)

This commit is contained in:
JT
2021-12-04 18:02:57 +13:00
committed by GitHub
parent df5ac9b71c
commit 8cf4402e6c
4 changed files with 110 additions and 33 deletions

View File

@ -6,9 +6,9 @@ use thiserror::Error;
/// forwards most methods, except for `.source_code()`, which we provide.
#[derive(Error)]
#[error("{0}")]
struct CliError<'src>(
&'src (dyn miette::Diagnostic + Send + Sync + 'static),
&'src StateWorkingSet<'src>,
pub struct CliError<'src>(
pub &'src (dyn miette::Diagnostic + Send + Sync + 'static),
pub &'src StateWorkingSet<'src>,
);
impl std::fmt::Debug for CliError<'_> {
@ -44,10 +44,3 @@ impl<'src> miette::Diagnostic for CliError<'src> {
Some(&self.1)
}
}
pub fn report_error(
working_set: &StateWorkingSet,
error: &(dyn miette::Diagnostic + Send + Sync + 'static),
) {
eprintln!("Error: {:?}", CliError(error, working_set));
}

View File

@ -5,7 +5,7 @@ mod syntax_highlight;
mod validation;
pub use completions::NuCompleter;
pub use errors::report_error;
pub use errors::CliError;
pub use prompt::NushellPrompt;
pub use syntax_highlight::NuHighlighter;
pub use validation::NuValidator;