Skip to content

Commit e1e50d1

Browse files
committed
Error messages for loading
1 parent 83cd95b commit e1e50d1

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

splashsurf/src/reconstruction.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ pub(crate) fn entry_point_generic<I: Index, R: Real>(
3939
) -> Result<(), anyhow::Error> {
4040
profile!("surface reconstruction cli");
4141

42-
info!(
43-
"Loading dataset from \"{}\"...",
44-
paths.input_file.to_string_lossy()
45-
);
42+
info!("Loading dataset from \"{}\"...", paths.input_file.display());
4643
let particle_positions = if let Some(extension) = paths.input_file.extension() {
4744
profile!("loading particle positions");
48-
let extension = extension.to_string_lossy();
45+
46+
let extension = extension.to_str().ok_or(anyhow!(
47+
"Invalid extension of of input file '{}'",
48+
paths.input_file.display()
49+
))?;
50+
4951
match extension.to_lowercase().as_str() {
5052
"vtk" => {
5153
let sph_dataset = io::read_vtk(&paths.input_file)?;
@@ -56,16 +58,17 @@ pub(crate) fn entry_point_generic<I: Index, R: Real>(
5658
return Err(anyhow!(
5759
"Unsupported file format extension '{}' of input file '{}'",
5860
extension,
59-
paths.input_file.to_string_lossy()
61+
paths.input_file.display()
6062
));
6163
}
6264
}
6365
} else {
6466
return Err(anyhow!(
65-
"Unable to detect file format of input file '{}'",
66-
paths.input_file.to_string_lossy()
67+
"Unable to detect file format of input file '{}' (file name has to end with supported extension)",
68+
paths.input_file.display()
6769
));
6870
};
71+
6972
info!(
7073
"Loaded dataset with {} particle positions.",
7174
particle_positions.len()

0 commit comments

Comments
 (0)