Skip to content

Commit 65ca01a

Browse files
committed
feat: improve invalid directory error message
1 parent cd2ba42 commit 65ca01a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/world/validate.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use thiserror::Error;
33

44
pub fn validate_worlds(worlds: &Vec<PathBuf>) -> Result<(), ValidateWorldError> {
55
for world in worlds {
6-
validate_world(&world)?;
6+
validate_world(world)?;
77
}
88
Ok(())
99
}
1010

1111
fn validate_world(world_dir: &Path) -> Result<(), ValidateWorldError> {
1212
if !world_dir.is_dir() {
13-
return Err(ValidateWorldError::NotADirectory);
13+
return Err(ValidateWorldError::NotADirectory(world_dir.to_path_buf()));
1414
}
1515

1616
if !std::fs::exists(world_dir.join("level.dat")).unwrap_or(false) {
@@ -22,8 +22,8 @@ fn validate_world(world_dir: &Path) -> Result<(), ValidateWorldError> {
2222

2323
#[derive(Error, Debug)]
2424
pub enum ValidateWorldError {
25-
#[error("the provided world directory is not a directory")]
26-
NotADirectory,
25+
#[error("the provided world `{0}` directory is not a directory")]
26+
NotADirectory(PathBuf),
2727
#[error("the provided world directory is missing the `level.dat` file")]
2828
MissingLevelData,
2929
}

0 commit comments

Comments
 (0)