Improve error handling and logging for map generation process

This commit is contained in:
2026-05-07 11:18:47 +02:00
parent b1ee6611b8
commit 95e51abc12

View File

@@ -457,9 +457,15 @@ async fn generate_map(
cmd.arg(arg);
}
let mut child = cmd
.spawn()
.map_err(|e| format!("Failed to start generator: {e}"))?;
let mut child = match cmd.spawn() {
Ok(child) => child,
Err(e) => {
write_log_line(&mut log_file, format!("result: spawn_failed: {e}"));
return Err(format!(
"Failed to start generator. Log: {log_path_display}\n{e}"
));
}
};
write_log_line(&mut log_file, format!("pid: {}", child.id()));
write_log_line(&mut log_file, "");
write_log_line(&mut log_file, "stdout:");
@@ -536,15 +542,22 @@ async fn generate_map(
));
}
let path_line =
last_path.ok_or_else(|| "Generator did not return a path".to_string())?;
let path_line = match last_path {
Some(path) => path,
None => {
write_log_line(&mut log_file, "result: missing_output_path");
return Err(format!(
"Generator did not return a path. Log: {log_path_display}"
));
}
};
let path = PathBuf::from(path_line.trim());
let resolved = if path.is_absolute() {
path
} else {
out_dir.join(path)
};
write_log_line(&mut log_file, format!("result: success"));
write_log_line(&mut log_file, "result: success");
write_log_line(
&mut log_file,
format!("output_path: {}", resolved.to_string_lossy()),