mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-06 03:22:59 +00:00
cli: translate last-minute EPIPE internally in handle_command_result()
This commit is contained in:
parent
ed1d2fde27
commit
f76830ab12
2 changed files with 8 additions and 5 deletions
|
@ -74,7 +74,7 @@ use tracing_subscriber::prelude::*;
|
|||
|
||||
use crate::command_error::{
|
||||
handle_command_result, internal_error, internal_error_with_message, user_error,
|
||||
user_error_with_hint, user_error_with_message, CommandError, BROKEN_PIPE_EXIT_CODE,
|
||||
user_error_with_hint, user_error_with_message, CommandError,
|
||||
};
|
||||
use crate::commit_templater::CommitTemplateLanguageExtension;
|
||||
use crate::config::{
|
||||
|
@ -2562,8 +2562,7 @@ impl CliRunner {
|
|||
let mut ui = Ui::with_config(&layered_configs.merge())
|
||||
.expect("default config should be valid, env vars are stringly typed");
|
||||
let result = self.run_internal(&mut ui, layered_configs);
|
||||
let exit_code = handle_command_result(&mut ui, result)
|
||||
.unwrap_or_else(|_| ExitCode::from(BROKEN_PIPE_EXIT_CODE));
|
||||
let exit_code = handle_command_result(&mut ui, result);
|
||||
ui.finalize_pager();
|
||||
exit_code
|
||||
}
|
||||
|
|
|
@ -436,9 +436,13 @@ impl From<GitIgnoreError> for CommandError {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) const BROKEN_PIPE_EXIT_CODE: u8 = 3;
|
||||
const BROKEN_PIPE_EXIT_CODE: u8 = 3;
|
||||
|
||||
pub(crate) fn handle_command_result(
|
||||
pub(crate) fn handle_command_result(ui: &mut Ui, result: Result<(), CommandError>) -> ExitCode {
|
||||
try_handle_command_result(ui, result).unwrap_or_else(|_| ExitCode::from(BROKEN_PIPE_EXIT_CODE))
|
||||
}
|
||||
|
||||
fn try_handle_command_result(
|
||||
ui: &mut Ui,
|
||||
result: Result<(), CommandError>,
|
||||
) -> io::Result<ExitCode> {
|
||||
|
|
Loading…
Reference in a new issue