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