From 790b5846f60c214e84a38354133b08926cb4d042 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 27 Mar 2024 23:04:14 +0900 Subject: [PATCH] sparse: don't use io::Error to report invalid path stored in repository I think it's more like data corruption, which is usually reported as an internal error. --- cli/src/commands/sparse.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cli/src/commands/sparse.rs b/cli/src/commands/sparse.rs index 140bfb7863..6c0fb351ca 100644 --- a/cli/src/commands/sparse.rs +++ b/cli/src/commands/sparse.rs @@ -14,7 +14,7 @@ use std::collections::HashSet; use std::fmt::Write as _; -use std::io::{self, Write}; +use std::io::Write; use std::path::Path; use clap::Subcommand; @@ -24,7 +24,9 @@ use jj_lib::settings::UserSettings; use tracing::instrument; use crate::cli_util::{edit_temp_file, print_checkout_stats, CommandHelper}; -use crate::command_error::{internal_error_with_message, user_error_with_message, CommandError}; +use crate::command_error::{ + internal_error, internal_error_with_message, user_error_with_message, CommandError, +}; use crate::ui::Ui; /// Manage which paths from the working-copy commit are present in the working @@ -152,13 +154,10 @@ fn edit_sparse( for sparse_path in sparse { let workspace_relative_sparse_path = sparse_path.to_fs_path(Path::new("")); let path_string = workspace_relative_sparse_path.to_str().ok_or_else(|| { - io::Error::new( - io::ErrorKind::InvalidData, - format!( - "stored sparse path is not valid utf-8: {}", - workspace_relative_sparse_path.display() - ), - ) + internal_error(format!( + "Stored sparse path is not valid utf-8: {}", + workspace_relative_sparse_path.display() + )) })?; writeln!(&mut content, "{}", path_string).unwrap(); }