From 98e0ea70e5c44ab23979c19b8059ffc67b74a524 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Fri, 30 May 2025 15:48:47 +0200 Subject: [PATCH] Improve file injection error handling --- crates/dtmt/src/cmd/bundle/inject.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/dtmt/src/cmd/bundle/inject.rs b/crates/dtmt/src/cmd/bundle/inject.rs index 21f4a91..23e3f8b 100644 --- a/crates/dtmt/src/cmd/bundle/inject.rs +++ b/crates/dtmt/src/cmd/bundle/inject.rs @@ -202,15 +202,13 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> { let bundle_name = Bundle::get_name_from_path(&ctx, bundle_path); let mut bundle = { - let binary = fs::read(bundle_path).await?; - Bundle::from_binary(&ctx, bundle_name.clone(), binary) + fs::read(bundle_path) + .await + .map_err(From::from) + .and_then(|binary| Bundle::from_binary(&ctx, bundle_name.clone(), binary)) .wrap_err_with(|| format!("Failed to open bundle '{}'", bundle_path.display()))? }; - if op == "copy" { - unimplemented!("Implement copying a file from one bundle to the other."); - } - let output_bundle = match op { "replace" => { let Some(file) = bundle @@ -280,6 +278,9 @@ pub(crate) async fn run(ctx: sdk::Context, matches: &ArgMatches) -> Result<()> { "add" => { unimplemented!("Implement adding a new file to the bundle."); } + "copy" => { + unimplemented!("Implement copying a file from one bundle to the other."); + } _ => unreachable!("no other operations exist"), }; -- 2.47.2