wasmer/lib/wasi/src/macros.rs

20 lines
557 B
Rust
Raw Normal View History

2019-04-01 23:34:18 +00:00
macro_rules! wasi_try {
($expr:expr) => {{
let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr;
match res {
2019-04-20 19:22:31 +00:00
Ok(val) => {
wasmer_runtime_core::trace!("wasi::wasi_try::val: {:?}", val);
2019-04-20 19:22:31 +00:00
val
}
Err(err) => {
wasmer_runtime_core::trace!("wasi::wasi_try::err: {:?}", err);
2019-04-20 19:22:31 +00:00
return err;
}
2019-04-01 23:34:18 +00:00
}
}};
($expr:expr, $e:expr) => {{
2019-04-01 23:34:18 +00:00
let opt: Option<_> = $expr;
wasi_try!(opt.ok_or($e))
}};
}