From 10286e0f9b43fec6c9ef5b733519b627b7f0e439 Mon Sep 17 00:00:00 2001 From: Arsenii Lyashenko Date: Thu, 3 Oct 2024 17:14:44 +0300 Subject: [PATCH] Log module errors --- sandbox/sandbox/src/embedded_executor.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sandbox/sandbox/src/embedded_executor.rs b/sandbox/sandbox/src/embedded_executor.rs index 36d2dcd2501..0ae5ebc9a48 100644 --- a/sandbox/sandbox/src/embedded_executor.rs +++ b/sandbox/sandbox/src/embedded_executor.rs @@ -278,7 +278,10 @@ impl super::SandboxMemory for Memory { fn new(store: &mut Store, initial: u32, maximum: Option) -> Result { let ty = MemoryType::new(initial, maximum, false); let memory_style = store.engine().tunables().memory_style(&ty); - let memref = VMMemory::new(&ty, &memory_style).map_err(|_| Error::Module)?; + let memref = VMMemory::new(&ty, &memory_style).map_err(|e| { + log::trace!("Failed to create memory: {e}"); + Error::Module + })?; // SAFETY: `vmmemory()` returns `NonNull` so pointer is valid let memory_definition = unsafe { memref.vmmemory().as_ref() }; let base = memory_definition.base as usize; @@ -437,7 +440,10 @@ impl super::SandboxInstance for Instance { .get(&key) .cloned() .and_then(|val| val.memory()) - .ok_or(Error::Module)? + .ok_or_else(|| { + log::trace!("Memory import for `{module}::{name}` not found"); + Error::Module + })? .memref; imports.define(&module, &name, mem); } @@ -447,7 +453,10 @@ impl super::SandboxInstance for Instance { .get(&key) .cloned() .and_then(|val| val.host_func()) - .ok_or(Error::Module)?; + .ok_or_else(|| { + log::trace!("Function import for `{module}::{name}` not found"); + Error::Module + })?; let func_ty = func_ty.clone();