Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add context to error messages #2408

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions crate_universe/src/cli/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ pub struct SpliceOptions {
/// Combine a set of disjoint manifests into a single workspace.
pub fn splice(opt: SpliceOptions) -> Result<()> {
// Load the all config files required for splicing a workspace
let splicing_manifest = SplicingManifest::try_from_path(&opt.splicing_manifest)?;
let splicing_manifest = SplicingManifest::try_from_path(&opt.splicing_manifest)
.context("Failed to parse splicing manifest")?;

// Determine the splicing workspace
let temp_dir;
Expand All @@ -77,7 +78,9 @@ pub fn splice(opt: SpliceOptions) -> Result<()> {
let splicer = Splicer::new(splicing_dir, splicing_manifest)?;

// Splice together the manifest
let manifest_path = splicer.splice_workspace(&opt.cargo)?;
let manifest_path = splicer
.splice_workspace(&opt.cargo)
.context("Failed to splice workspace")?;

let cargo = Cargo::new(opt.cargo);

Expand All @@ -88,30 +91,35 @@ pub fn splice(opt: SpliceOptions) -> Result<()> {
cargo.clone(),
&opt.rustc,
&opt.repin,
)?;
)
.context("Failed to generate lockfile")?;

let config = Config::try_from_path(&opt.config)?;
let config = Config::try_from_path(&opt.config).context("Failed to parse config")?;

let feature_map = FeatureGenerator::new(cargo.clone(), opt.rustc.clone()).generate(
manifest_path.as_path_buf(),
&config.supported_platform_triples,
)?;
let feature_map = FeatureGenerator::new(cargo.clone(), opt.rustc.clone())
.generate(
manifest_path.as_path_buf(),
&config.supported_platform_triples,
)
.context("Failed to generate features")?;
// Write the registry url info to the manifest now that a lockfile has been generated
WorkspaceMetadata::write_registry_urls_and_feature_map(
&cargo,
&cargo_lockfile,
feature_map,
manifest_path.as_path_buf(),
manifest_path.as_path_buf(),
)?;
)
.context("Failed to write registry URLs and feature map")?;

let output_dir = opt.output_dir.clone();

// Write metadata to the workspace for future reuse
let (cargo_metadata, _) = Generator::new()
.with_cargo(cargo)
.with_rustc(opt.rustc)
.generate(manifest_path.as_path_buf())?;
.generate(manifest_path.as_path_buf())
.context("Failed to generate cargo metadata")?;

let cargo_lockfile_path = manifest_path
.as_path_buf()
Expand All @@ -128,7 +136,8 @@ pub fn splice(opt: SpliceOptions) -> Result<()> {
std::fs::create_dir_all(&output_dir)
.with_context(|| format!("Failed to create directories for {}", &output_dir.display()))?;

write_metadata(&opt.output_dir.join("metadata.json"), &cargo_metadata)?;
write_metadata(&opt.output_dir.join("metadata.json"), &cargo_metadata)
.context("Failed to write metadata")?;

std::fs::copy(cargo_lockfile_path, output_dir.join("Cargo.lock"))
.context("Failed to copy lockfile")?;
Expand Down
Loading