mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
errors: don't use the ui.hint*()
helpers
I'm about to make hints not get printed with `--quiet`, but error hints are probably still useful to get. They shouldn't be a problem for scripts since the script would have to deal with the error anyway.
This commit is contained in:
parent
aeaab8aad3
commit
b940f1a092
1 changed files with 11 additions and 10 deletions
|
@ -561,7 +561,7 @@ fn try_handle_command_result(
|
|||
CommandErrorKind::Config => {
|
||||
print_error(ui, "Config error: ", err, hints)?;
|
||||
writeln!(
|
||||
ui.hint_no_heading(),
|
||||
ui.stderr_formatter().labeled("hint"),
|
||||
"For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md."
|
||||
)?;
|
||||
Ok(ExitCode::from(1))
|
||||
|
@ -619,13 +619,14 @@ fn print_error_sources(ui: &Ui, source: Option<&dyn error::Error>) -> io::Result
|
|||
|
||||
fn print_error_hints(ui: &Ui, hints: &[ErrorHint]) -> io::Result<()> {
|
||||
for hint in hints {
|
||||
match hint {
|
||||
ErrorHint::PlainText(message) => {
|
||||
writeln!(ui.hint_default(), "{message}")?;
|
||||
}
|
||||
ErrorHint::Formatted(recorded) => {
|
||||
ui.stderr_formatter().with_label("hint", |formatter| {
|
||||
write!(formatter.labeled("heading"), "Hint: ")?;
|
||||
ui.stderr_formatter().with_label("hint", |formatter| {
|
||||
write!(formatter.labeled("heading"), "Hint: ")?;
|
||||
match hint {
|
||||
ErrorHint::PlainText(message) => {
|
||||
writeln!(formatter, "{message}")?;
|
||||
Ok(())
|
||||
}
|
||||
ErrorHint::Formatted(recorded) => {
|
||||
recorded.replay(formatter)?;
|
||||
// Formatted hint is usually multi-line text, and it's
|
||||
// convenient if trailing "\n" doesn't have to be omitted.
|
||||
|
@ -633,9 +634,9 @@ fn print_error_hints(ui: &Ui, hints: &[ErrorHint]) -> io::Result<()> {
|
|||
writeln!(formatter)?;
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue