mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:15:49 +02:00
Generalize nu_protocol::format_shell_error
(#15996)
This commit is contained in:
@ -8,7 +8,7 @@ use notify_debouncer_full::{
|
||||
use nu_engine::{ClosureEval, command_prelude::*};
|
||||
use nu_protocol::{
|
||||
engine::{Closure, StateWorkingSet},
|
||||
format_shell_error,
|
||||
format_cli_error,
|
||||
shell_error::io::IoError,
|
||||
};
|
||||
use std::{
|
||||
@ -208,7 +208,7 @@ impl Command for Watch {
|
||||
}
|
||||
Err(err) => {
|
||||
let working_set = StateWorkingSet::new(engine_state);
|
||||
eprintln!("{}", format_shell_error(&working_set, &err));
|
||||
eprintln!("{}", format_cli_error(&working_set, &err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ fn should_show_warning(engine_state: &EngineState, warning: &ParseWarning) -> bo
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_shell_error(working_set: &StateWorkingSet, error: &ShellError) -> String {
|
||||
pub fn format_cli_error(working_set: &StateWorkingSet, error: &dyn miette::Diagnostic) -> String {
|
||||
format!("Error: {:?}", CliError(error, working_set))
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ mod parse_warning;
|
||||
pub mod shell_error;
|
||||
|
||||
pub use cli_error::{
|
||||
ReportMode, format_shell_error, report_parse_error, report_parse_warning, report_shell_error,
|
||||
ReportMode, format_cli_error, report_parse_error, report_parse_warning, report_shell_error,
|
||||
report_shell_warning,
|
||||
};
|
||||
pub use compile_error::CompileError;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::chained_error::ChainedError;
|
||||
use crate::{
|
||||
ConfigError, LabeledError, ParseError, Span, Spanned, Type, Value, ast::Operator,
|
||||
engine::StateWorkingSet, format_shell_error, record,
|
||||
engine::StateWorkingSet, format_cli_error, record,
|
||||
};
|
||||
use job::JobError;
|
||||
use miette::Diagnostic;
|
||||
@ -1418,7 +1418,7 @@ impl ShellError {
|
||||
"msg" => Value::string(self.to_string(), span),
|
||||
"debug" => Value::string(format!("{self:?}"), span),
|
||||
"raw" => Value::error(self.clone(), span),
|
||||
"rendered" => Value::string(format_shell_error(working_set, &self), span),
|
||||
"rendered" => Value::string(format_cli_error(working_set, &self), span),
|
||||
"json" => Value::string(serde_json::to_string(&self).expect("Could not serialize error"), span),
|
||||
};
|
||||
|
||||
@ -1431,7 +1431,7 @@ impl ShellError {
|
||||
|
||||
// TODO: Implement as From trait
|
||||
pub fn wrap(self, working_set: &StateWorkingSet, span: Span) -> ParseError {
|
||||
let msg = format_shell_error(working_set, &self);
|
||||
let msg = format_cli_error(working_set, &self);
|
||||
ParseError::LabeledError(
|
||||
msg,
|
||||
"Encountered error during parse-time evaluation".into(),
|
||||
|
Reference in New Issue
Block a user