mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-01 18:09:15 +08:00
Merge pull request #2508 from fufesou/feat_allow_err
allow_err with msg
This commit is contained in:
commit
dcdcf62140
@ -66,6 +66,21 @@ macro_rules! allow_err {
|
||||
} else {
|
||||
}
|
||||
};
|
||||
|
||||
($e:expr, $($arg:tt)*) => {
|
||||
if let Err(err) = $e {
|
||||
log::debug!(
|
||||
"{:?}, {}, {}:{}:{}:{}",
|
||||
err,
|
||||
format_args!($($arg)*),
|
||||
module_path!(),
|
||||
file!(),
|
||||
line!(),
|
||||
column!()
|
||||
);
|
||||
} else {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -250,4 +265,10 @@ mod tests {
|
||||
let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(192, 168, 16, 32), 21116));
|
||||
assert_eq!(addr, AddrMangle::decode(&AddrMangle::encode(addr)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_allow_err() {
|
||||
allow_err!(Err("test err") as Result<(), &str>);
|
||||
allow_err!(Err("test err with msg") as Result<(), &str>, "prompt {}", "failed");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user