Skip to content

Commit 5337c08

Browse files
feat: add logging for mod entry checks and improve error handling in YAML parsing
1 parent ed09f82 commit 5337c08

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/main.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,13 @@ fn get_installed_mods_sync(mods_folder_path: String) -> Vec<LocalMod> {
159159

160160
for entry in fs::read_dir(mods_folder_path).unwrap() {
161161
let entry = entry.unwrap();
162+
println!("Checking mod entry: {:?}", entry.file_name());
162163
let res: anyhow::Result<_> = try {
163-
let yaml = if entry.file_type().unwrap().is_dir() {
164+
if false {
165+
anyhow::Ok(())?
166+
}
167+
168+
let yaml = if entry.file_type().context("invalid file type")?.is_dir() {
164169
let cache_path = entry.path().read_dir().unwrap().find(|v| {
165170
v.as_ref()
166171
.map(|v| {
@@ -212,7 +217,12 @@ fn get_installed_mods_sync(mods_folder_path: String) -> Vec<LocalMod> {
212217
continue;
213218
};
214219

215-
let yaml: serde_yaml::Value = serde_yaml::from_str(&yaml).unwrap();
220+
let yaml = serde_yaml::from_str(&yaml);
221+
if let Err(e) = yaml {
222+
println!("[ WARNING ] Failed to parse {:?}: {}", entry.file_name(), e);
223+
continue;
224+
}
225+
let yaml: serde_yaml::Value = yaml.unwrap();
216226

217227
let mut deps: Vec<ModDependency> = Vec::new();
218228

0 commit comments

Comments
 (0)