Skip to content

Commit

Permalink
sparse: don't use io::Error to report invalid path stored in repository
Browse files Browse the repository at this point in the history
I think it's more like data corruption, which is usually reported as an
internal error.
  • Loading branch information
yuja committed Mar 27, 2024
1 parent a3462c4 commit 7ff74f7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions cli/src/commands/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 7ff74f7

Please sign in to comment.