From 81d8e4ee2e1bf1f5b4f051d8e4af262be43703f4 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 12 Jun 2019 11:35:29 +0200 Subject: [PATCH] feat(runtime-c-api) Improve error message when compiling a module. --- lib/runtime-c-api/src/module.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/runtime-c-api/src/module.rs b/lib/runtime-c-api/src/module.rs index dbd676f1066..b245fddd78c 100644 --- a/lib/runtime-c-api/src/module.rs +++ b/lib/runtime-c-api/src/module.rs @@ -129,14 +129,14 @@ pub unsafe extern "C" fn wasmer_module_instantiate( } let module = &*(module as *const Module); - let new_instance = if let Ok(res) = module.instantiate(&import_object) { - res - } else { - update_last_error(CApiError { - msg: "error instantiating from module".to_string(), - }); - return wasmer_result_t::WASMER_ERROR; + let new_instance = match module.instantiate(&import_object) { + Ok(instance) => instance, + Err(error) => { + update_last_error(error); + return wasmer_result_t::WASMER_ERROR; + } }; + *instance = Box::into_raw(Box::new(new_instance)) as *mut wasmer_instance_t; wasmer_result_t::WASMER_OK }