Replace all TODOs wanting a custom error with a generic custom error.
This commit is contained in:
parent
a1adf2aa41
commit
cd2daf6fef
@ -11,7 +11,7 @@ pub enum CustomError<I> {
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct MyError<I>(I);
|
||||
pub struct MyError<I>(pub I);
|
||||
|
||||
impl<I> ParseError<I> for CustomError<I> {
|
||||
fn from_error_kind(input: I, kind: ErrorKind) -> Self {
|
||||
|
@ -6,6 +6,7 @@ use nom::error::VerboseError;
|
||||
use nom::IResult;
|
||||
|
||||
use super::error::CustomError;
|
||||
use super::error::MyError;
|
||||
use super::list::List;
|
||||
use super::list::Node;
|
||||
use super::token::Token;
|
||||
@ -63,12 +64,12 @@ impl<'r, 's> ContextTree<'r, 's> {
|
||||
if local_result.is_ok() {
|
||||
return local_result;
|
||||
}
|
||||
// TODO: Make this a custom error
|
||||
not(take(0usize))(i)?;
|
||||
// TODO: Make this a specific error instead of just a generic MyError
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError("NoExit"))));
|
||||
}
|
||||
ChainBehavior::IgnoreParent(None) => {
|
||||
// TODO: Make this a custom error
|
||||
not(take(0usize))(i)?;
|
||||
// TODO: Make this a specific error instead of just a generic MyError
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError("NoExit"))));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -77,9 +78,8 @@ impl<'r, 's> ContextTree<'r, 's> {
|
||||
ContextElement::Context(_) => {}
|
||||
};
|
||||
}
|
||||
// TODO: Make this a custom error
|
||||
not(take(0usize))(i)?;
|
||||
unreachable!()
|
||||
// TODO: Make this a specific error instead of just a generic MyError
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError("NoExit"))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
use crate::parser::text::paragraph_end;
|
||||
|
||||
use super::error::CustomError;
|
||||
use super::error::MyError;
|
||||
use super::nom_context::ChainBehavior;
|
||||
use super::nom_context::ContextElement;
|
||||
use super::nom_context::ContextTree;
|
||||
@ -181,9 +183,8 @@ pub fn context_bold_start<'s, 'r>(
|
||||
if can_start_bold(context) {
|
||||
recognize(bold_start)(input)
|
||||
} else {
|
||||
// TODO: Make this a custom error
|
||||
not(take(0usize))(input)?;
|
||||
unreachable!()
|
||||
// TODO: Make this a specific error instead of just a generic MyError
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError("Cannot start bold"))));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user