From 8f118074fe871b6f394a16f2bdd27e206eec0227 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 31 Jan 2024 23:57:35 +0900 Subject: [PATCH] cli: map bare io::Error to user error Suppose the error is emitted from Ui or external command, I don't think io::Error in CLI is an internal error. --- cli/src/cli_util.rs | 2 +- cli/tests/test_next_prev_commands.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index cbb515645..8c4c9328f 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -134,7 +134,7 @@ impl From for CommandError { CommandError::BrokenPipe } else { // TODO: Record the error as a chained cause - CommandError::InternalError(format!("I/O error: {err}")) + user_error(format!("I/O error: {err}")) } } } diff --git a/cli/tests/test_next_prev_commands.rs b/cli/tests/test_next_prev_commands.rs index 3059cf6c7..71a25eef8 100644 --- a/cli/tests/test_next_prev_commands.rs +++ b/cli/tests/test_next_prev_commands.rs @@ -146,10 +146,10 @@ fn test_next_fails_on_branching_children_no_stdin() { test_env.jj_cmd_ok(&repo_path, &["co", "@--"]); // Try to advance the working copy commit. - let assert = test_env.jj_cmd(&repo_path, &["next"]).assert().code(255); + let assert = test_env.jj_cmd(&repo_path, &["next"]).assert().code(1); let stderr = test_env.normalize_output(&get_stderr_string(&assert)); insta::assert_snapshot!(stderr,@r###" - Internal error: I/O error: Cannot prompt for input since the output is not connected to a terminal + Error: I/O error: Cannot prompt for input since the output is not connected to a terminal "###); }