Macro skip_error::skip_error_and_error[][src]

macro_rules! skip_error_and_error {
    ($result : expr) => { ... };
}
Expand description

skip_error_and_error returns the value of a Result or log with tracing::Level::ERROR and continues the loop.

skip_error_and_error macro takes one parameter which is of type Result.The macro returns the value if Result::Ok and else,it logs the Result::Err with level tracing::Level::ERROR and calls continue.

For example

for string_number in &["1", "2", "three", "4"] {
  let number: u32 = skip_error_and_error!(string_number.parse());
}
testing_logger::validate(|captured_logs| {
  assert!(captured_logs[0].body.contains("invalid digit found in string"));
  assert_eq!(captured_logs[0].level, log::Level::Error);
});