Skip to content

Commit d57eb01

Browse files
committed
f
1 parent e8eb116 commit d57eb01

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

bindings/rust/src/lib.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,23 @@ impl Module {
238238
// Forget Module (and avoid calling drop) because it has been consumed by instantiate (even if it failed).
239239
core::mem::forget(self);
240240
if ptr.is_null() {
241-
return Err("Invalid ptr".into());
242-
}
243-
let instance = unsafe { NonNull::new_unchecked(ptr) };
244-
Ok(Instance {
245-
instance: instance,
246-
module: Module {
247-
ptr: unsafe {
248-
ConstNonNull::new_unchecked(sys::fizzy_get_instance_module(instance.as_ptr()))
241+
debug_assert!(err.code() != 0);
242+
Err(err.error().unwrap())
243+
} else {
244+
debug_assert!(err.code() == 0);
245+
let instance = unsafe { NonNull::new_unchecked(ptr) };
246+
Ok(Instance {
247+
instance: instance,
248+
module: Module {
249+
ptr: unsafe {
250+
ConstNonNull::new_unchecked(sys::fizzy_get_instance_module(
251+
instance.as_ptr(),
252+
))
253+
},
254+
owned: false,
249255
},
250-
owned: false,
251-
},
252-
})
256+
})
257+
}
253258
}
254259

255260
/// Returns true if the module has a start function defined.

0 commit comments

Comments
 (0)