Skip to content

Commit 24c506e

Browse files
authored
fix(boil): Return error if docker child process fails (#1252)
1 parent a57bec3 commit 24c506e

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

rust/boil/src/build/mod.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ pub enum Error {
3737
#[snafu(display("failed to spawn child process"))]
3838
SpawnChildProcess { source: std::io::Error },
3939

40+
#[snafu(display(
41+
"the docker child process failed with code {code}",
42+
code = code.map_or("unknown".to_owned(), |c| c.to_string())
43+
))]
44+
ChildProcessFailed { code: Option<i32> },
45+
4046
#[snafu(display("encountered invalid image version, must not include any build metadata"))]
4147
InvalidImageVersion,
4248
}
@@ -99,14 +105,19 @@ pub fn run_command(args: BuildArguments, config: Config) -> Result<(), Error> {
99105
// Wait for successful completion of the child process
100106
let status = child.wait().context(RunChildProcessSnafu)?;
101107

102-
// TODO (@Techassi): Return an error if the status was not a success
103-
if status.success() {
104-
println!(
105-
"Successfully built {count} image{plural}:\n{images}",
106-
plural = if count > 1 { "s" } else { "" },
107-
images = image_manifest_uris.join("\n")
108-
);
109-
}
108+
// Return an error if the child process failed
109+
ensure!(
110+
status.success(),
111+
ChildProcessFailedSnafu {
112+
code: status.code()
113+
}
114+
);
115+
116+
println!(
117+
"Successfully built {count} image{plural}:\n{images}",
118+
plural = if count > 1 { "s" } else { "" },
119+
images = image_manifest_uris.join("\n")
120+
);
110121

111122
Ok(())
112123
}

0 commit comments

Comments
 (0)