Macro nom::add_return_error [−][src]
macro_rules! add_return_error { ($i:expr, $code:expr, $submac:ident!( $($args:tt)* )) => { ... }; ($i:expr, $code:expr, $f:expr) => { ... }; }
Add an error if the child parser fails
While error! does an early return and avoids backtracking, add_return_error! backtracks normally. It just provides more context for an error
named!(err_test, add_return_error!(ErrorKind::Custom(42u32), tag!("abcd"))); let a = &b"efghblah"[..]; let res_a = err_test(a); assert_eq!(res_a, Err(Err::Error(error_node_position!(a, ErrorKind::Custom(42), error_position!(a, ErrorKind::Tag)))));