Skip to content

Commit

Permalink
bail
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Feb 1, 2024
1 parent 021e08f commit c6e0273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Tools for creating and inserting into tarballs.
use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait;
use camino::Utf8Path;
use flate2::write::GzEncoder;
Expand Down Expand Up @@ -106,10 +106,10 @@ pub async fn add_package_to_zone_archive<E: Encoder>(
let tmp = camino_tempfile::tempdir()?;
let gzr = flate2::read::GzDecoder::new(open_tarfile(package_path)?);
if gzr.header().is_none() {
return Err(anyhow!(
bail!(
"Missing gzip header from {} - cannot add it to zone image",
package_path,
));
);
}
let mut component_reader = tar::Archive::new(gzr);
let entries = component_reader.entries()?;
Expand Down
10 changes: 5 additions & 5 deletions src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn zone_get_all_parent_inputs(to: &Utf8Path) -> Result<Vec<TargetDirectory>> {
parents.reverse();

if to.is_relative() {
return Err(anyhow!("Cannot add 'to = {to}'; absolute path required",));
bail!("Cannot add 'to = {to}'; absolute path required");
}

let mut outputs = vec![];
Expand Down Expand Up @@ -452,11 +452,11 @@ impl Package {
if !from.exists() {
// Strictly speaking, this check is redundant, but it provides
// a better error message.
return Err(anyhow!(
bail!(
"Cannot add path \"{}\" to package \"{}\" because it does not exist",
from,
self.service_name,
));
);
}

let from_root = std::fs::canonicalize(&from)
Expand Down Expand Up @@ -543,10 +543,10 @@ impl Package {
}
}
_ => {
return Err(anyhow!(
bail!(
"Cannot walk over a zone package with source: {:?}",
self.source
));
);
}
}

Expand Down

0 comments on commit c6e0273

Please sign in to comment.