nom::add_error! [] [src]

macro_rules! add_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_error! backtracks normally. It just provides more context for an error

    named!(err_test, add_error!(ErrorKind::Custom(42), tag!("abcd")));

    let a = &b"efghblah"[..];
    let res_a = err_test(a);
    assert_eq!(res_a, Error(NodePosition(ErrorKind::Custom(42), a, Box::new(Position(ErrorKind::Tag, a)))));