Skip to content

Commit

Permalink
Give better errors when build-manifest fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Oct 1, 2022
1 parent 513fc80 commit d44e142
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ macro_rules! t {
Err(e) => panic!("{} failed with {}", stringify!($e), e),
}
};
($e:expr, $extra:expr) => {
match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {}: {}", stringify!($e), e, $extra),
}
};
}

struct Builder {
Expand Down Expand Up @@ -584,7 +590,7 @@ impl Builder {
self.shipped_files.insert(name.clone());

let dst = self.output.join(name);
t!(fs::write(&dst, contents));
t!(fs::write(&dst, contents), format!("failed to create manifest {}", dst.display()));
}

fn write_shipped_files(&self, path: &Path) {
Expand Down
4 changes: 4 additions & 0 deletions src/tools/build-manifest/src/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ impl Versions {
Some(version) => Ok(version.clone()),
None => {
let version_info = self.load_version_from_tarball(package)?;
if *package == PkgType::Rust && version_info.version.is_none() {
panic!("missing version info for toolchain");
}
self.versions.insert(package.clone(), version_info.clone());
Ok(version_info)
}
Expand All @@ -131,6 +134,7 @@ impl Versions {
Ok(file) => file,
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
// Missing tarballs do not return an error, but return empty data.
println!("warning: missing tarball {}", tarball.display());
return Ok(VersionInfo::default());
}
Err(err) => return Err(err.into()),
Expand Down

0 comments on commit d44e142

Please sign in to comment.