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) => {
|
2019-05-15 18:46:17 +00:00
|
|
|
wasmer_runtime_core::trace!("wasi::wasi_try::val: {:?}", val);
|
2019-04-20 19:22:31 +00:00
|
|
|
val
|
|
|
|
}
|
|
|
|
Err(err) => {
|
2019-05-15 18:46:17 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}};
|
2019-07-19 18:47:31 +00:00
|
|
|
($expr:expr, $e:expr) => {{
|
2019-04-01 23:34:18 +00:00
|
|
|
let opt: Option<_> = $expr;
|
|
|
|
wasi_try!(opt.ok_or($e))
|
|
|
|
}};
|
|
|
|
}
|