Skip to content

Commit

Permalink
Improve error messages when --bundle-to dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Jan 21, 2025
1 parent 48a09bb commit b59778d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion imageflow_tool/src/cmd_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,18 @@ impl CmdBuild {
// Write new invocation to STDOUT, for execution in 'directory'.
// Will write recipe and dependencies into directory
pub fn bundle_to(self, directory: &Path) -> i32{
std::fs::create_dir(directory).unwrap();
match std::fs::create_dir(directory) {
Ok(_) => (),
Err(e) => {
if e.kind() == std::io::ErrorKind::AlreadyExists {
eprintln!("Error: --bundle-to target directory already exists: {}", e);
return 1;
} else {
eprintln!("Failed to create directory: {}", e);
return 1;
}
}
}
let (log, transformed) = CmdBuild::transform_build(self.job.unwrap(), directory).unwrap();
CmdBuild::write_json(&directory.join("recipe.json"), &transformed);
println!("cd {:?}", &directory);
Expand Down

0 comments on commit b59778d

Please sign in to comment.