Skip to content

Commit 13de15f

Browse files
committed
handle errors in traversal
1 parent 5ccce69 commit 13de15f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/src/api.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,20 @@ impl OntoEnv {
11201120
continue;
11211121
}
11221122
for entry in walkdir::WalkDir::new(location) {
1123-
let entry = entry?;
1123+
let entry = match entry {
1124+
Ok(entry) => entry,
1125+
Err(err) => {
1126+
if self.config.strict {
1127+
return Err(err.into());
1128+
}
1129+
let path = err
1130+
.path()
1131+
.map(|p| p.display().to_string())
1132+
.unwrap_or_else(|| location.display().to_string());
1133+
warn!("Skipping {path} due to filesystem error: {err}");
1134+
continue;
1135+
}
1136+
};
11241137
if entry.file_type().is_file() && self.config.is_included(entry.path()) {
11251138
files.insert(OntologyLocation::File(entry.path().to_path_buf()));
11261139
}

0 commit comments

Comments
 (0)