add try_print!() macro

master
rasul 5 years ago
parent 7ef856cf19
commit ed2a52da4b

@ -13,6 +13,21 @@ macro_rules! try_log {
}; };
} }
/// Unwrap a Result and print if it's an error
#[macro_export]
macro_rules! try_print {
($e:expr, $($arg:tt)*) => {
match $e {
Ok(r) => r,
Err(e) => {
let s = std::fmt::format(format_args!($($arg)*));
println!("{}({}) :: {} :: {}", file!(), line!(), s, e);
return Err(Box::from(e));
}
}
};
}
/// Unwrap a Result<T, E>, if it's an error then let client know and return. /// Unwrap a Result<T, E>, if it's an error then let client know and return.
#[macro_export] #[macro_export]
macro_rules! try_send_error { macro_rules! try_send_error {

Loading…
Cancel
Save