Skip to content

Commit d211229

Browse files
committed
More diagnostics
1 parent ae6f777 commit d211229

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,30 +630,33 @@ impl MoonBitComponent {
630630
let mut wasm = std::fs::read(&module_wasm)
631631
.context(format!("Failed to read module WASM from {module_wasm}"))?;
632632

633-
wit_component::embed_component_metadata(&mut wasm, resolve, *world, StringEncoding::UTF16)?;
633+
wit_component::embed_component_metadata(&mut wasm, resolve, *world, StringEncoding::UTF16)
634+
.context("Embedding component metadata")?;
634635

635-
std::fs::write(self.module_with_embed_wasm(), wasm)?;
636+
std::fs::write(self.module_with_embed_wasm(), wasm)
637+
.context("Writing WASM with embedded metadata")?;
636638

637639
Ok(())
638640
}
639641

640642
fn create_component(&self, target: &Utf8Path) -> anyhow::Result<()> {
641643
info!("Creating the final WASM component at {target}");
642644

643-
let wasm = std::fs::read(self.module_with_embed_wasm())?;
645+
let wasm = std::fs::read(self.module_with_embed_wasm())
646+
.context("Reading WASM with embedded metadata")?;
644647
let mut encoder = ComponentEncoder::default()
645648
.validate(true)
646649
.reject_legacy_names(false)
647650
.merge_imports_based_on_semver(true)
648651
.realloc_via_memory_grow(false)
649652
.module(&wasm)?;
650653

651-
let component = encoder.encode()?;
654+
let component = encoder.encode().context("Encoding WASM component")?;
652655

653656
if let Some(parent) = target.parent() {
654-
std::fs::create_dir_all(parent)?;
657+
std::fs::create_dir_all(parent).context("Creating directory for WASM component")?;
655658
}
656-
std::fs::write(target, component)?;
659+
std::fs::write(target, component).context("Writing WASM component")?;
657660

658661
Ok(())
659662
}

0 commit comments

Comments
 (0)