Create a custom error enum to contain regular nom errors.
This commit is contained in:
parent
4a9bb31aed
commit
f2e68612c4
@ -276,29 +276,30 @@ fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<
|
||||
Ok((remaining, ret))
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum CustomError<I> {
|
||||
MyError(MyError<I>),
|
||||
Nom(I, ErrorKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct MyError<I>(I);
|
||||
|
||||
impl<I> ParseError<I> for MyError<I> {
|
||||
impl<I> ParseError<I> for CustomError<I> {
|
||||
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
|
||||
// MyError((input, kind))
|
||||
todo!()
|
||||
CustomError::Nom(input, kind)
|
||||
}
|
||||
|
||||
fn append(input: I, kind: ErrorKind, mut other: Self) -> Self {
|
||||
// Doesn't do append like VerboseError
|
||||
other
|
||||
}
|
||||
|
||||
fn from_char(input: I, c: char) -> Self {
|
||||
// MyError((input, c))
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
// Err(nom::Err::Error(nom::error::Error::from_error_kind(input, nom::error::ErrorKind::Char)))
|
||||
|
||||
|
||||
fn test_parser<'a>(i: &'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>> {
|
||||
Err(nom::Err::Error(MyError(i)))?;
|
||||
fn test_parser<'a>(i: &'a str) -> IResult<&'a str, &'a str, CustomError<&'a str>> {
|
||||
Err(nom::Err::Error(CustomError::MyError(MyError(i))))?;
|
||||
tag("sdjfisdfjisudfjuwiefweufefefjwef")(i)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user