mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 14:25:32 +00:00
replace expect with map_err
This commit is contained in:
parent
fed80fcd3e
commit
a304cdac03
@ -525,20 +525,21 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
args.push(Value::I32(x));
|
args.push(Value::I32(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = instance
|
let index = instance.resolve_func("_start").map_err(|_| {
|
||||||
.resolve_func("_start")
|
format!("The loader requires a _start function to be present in the module")
|
||||||
.expect("The loader requires a _start function to be present in the module");
|
})?;
|
||||||
|
|
||||||
let mut ins: Box<dyn LoadedInstance<Error = String>> = match loader {
|
let mut ins: Box<dyn LoadedInstance<Error = String>> = match loader {
|
||||||
LoaderName::Local => Box::new(
|
LoaderName::Local => Box::new(
|
||||||
instance
|
instance
|
||||||
.load(LocalLoader)
|
.load(LocalLoader)
|
||||||
.expect("Can't use the local loader"),
|
.map_err(|e| format!("Can't use the local loader: {:?}", e))?,
|
||||||
),
|
),
|
||||||
#[cfg(feature = "loader-kernel")]
|
#[cfg(feature = "loader-kernel")]
|
||||||
LoaderName::Kernel => Box::new(
|
LoaderName::Kernel => Box::new(
|
||||||
instance
|
instance
|
||||||
.load(::wasmer_kernel_loader::KernelLoader)
|
.load(::wasmer_kernel_loader::KernelLoader)
|
||||||
.expect("Can't use the kernel loader"),
|
.map_err(|e| format!("Can't use the local loader: {:?}", e))?,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
println!("{:?}", ins.call(index, &args));
|
println!("{:?}", ins.call(index, &args));
|
||||||
@ -610,7 +611,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
|||||||
f.read_to_end(&mut out).unwrap();
|
f.read_to_end(&mut out).unwrap();
|
||||||
Some(
|
Some(
|
||||||
wasmer_runtime_core::state::InstanceImage::from_bytes(&out)
|
wasmer_runtime_core::state::InstanceImage::from_bytes(&out)
|
||||||
.expect("failed to decode image"),
|
.map_err(|_| format!("failed to decode image"))?,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
Loading…
Reference in New Issue
Block a user