remove output file on error

This commit is contained in:
mos 2024-07-28 12:08:31 +02:00
parent eb99ba7119
commit ea09723455
1 changed files with 4 additions and 1 deletions

View File

@ -61,7 +61,10 @@ pub fn run(path: &str, outfile: &str) -> Result<()> {
bp::Writer::new() bp::Writer::new()
.parse_tree(&node_tree) .parse_tree(&node_tree)
.map_err(Error::BpError)? .or_else(|e| {
std::fs::remove_file(outfile).map_err(Error::BadWrite)?;
Err(Error::BpError(e))
})?
.write_to(&mut out) .write_to(&mut out)
.map_err(Error::BadWrite) .map_err(Error::BadWrite)
} }