Macro skip_error::skip_error_and_trace [−][src]
macro_rules! skip_error_and_trace {
($result : expr) => { ... };
}
Expand description
skip_error_and_trace
returns the value of a Result
or log with tracing::Level::TRACE
and continues the loop.
skip_error_and_trace
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::TRACE
and calls continue
.
For example
ⓘ
for string_number in &["1", "2", "three", "4"] {
let number: u32 = skip_error_and_trace!(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::Trace);
});