[−][src]Macro nom::fix_error
translate parser result from IResult<I,O,u32> to IResult<I,O,E> with a custom type
// will add a Custom(42) error to the error chain
named!(err_test, add_return_error!(ErrorKind::Custom(42), tag!("abcd")));
// Convert to IREsult<&[u8], &[u8], &str>
named!(parser<&[u8], &[u8], &str>, add_return_error!(ErrorKind::Custom("custom error message"), fix_error!(&str, err_test)));
let a = &b"efghblah"[..];
let res_a = parser(a);
assert_eq!(res_a, Error(error_node_position!( ErrorKind::Custom("custom error message"), a, Position(ErrorKind::Fix, a))));