Continue removing MyError.

This commit is contained in:
Tom Alexander 2023-10-17 10:13:00 -04:00
parent 77e6c22ad8
commit e776a051ad
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 10 additions and 16 deletions

View File

@ -107,7 +107,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
pub(crate) fn check_exit_matcher(
&'r self,
i: OrgSource<'s>,
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> {
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError> {
let mut current_class_filter = ExitClass::Gamma;
for current_node in self.iter_context() {
let context_element = current_node.get_data();

View File

@ -101,7 +101,7 @@ pub fn parse_file_with_settings<'g, 's, P: AsRef<Path>>(
/// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
#[allow(dead_code)]
fn document<'s>(context: RefContext<'_, '_, '_, 's>, input: &'s str) -> Res<&'s str, Document<'s>> {
let (remaining, doc) = document_org_source(context, input.into()).map_err(convert_error)?;
let (remaining, doc) = document_org_source(context, input.into())?;
Ok((Into::<&str>::into(remaining), doc))
}
@ -132,9 +132,9 @@ fn document_org_source<'b, 'g, 'r, 's>(
let (_, setup_file_settings) =
scan_for_in_buffer_settings(setup_file.into()).map_err(|err| {
eprintln!("{}", err);
nom::Err::Error(CustomError::MyError(MyError(
nom::Err::Error(CustomError::Static(
"TODO: make this take an owned string so I can dump err.to_string() into it.",
)))
))
})?;
final_settings.extend(setup_file_settings);
}
@ -142,9 +142,9 @@ fn document_org_source<'b, 'g, 'r, 's>(
let new_settings = apply_in_buffer_settings(final_settings, context.get_global_settings())
.map_err(|err| {
eprintln!("{}", err);
nom::Err::Error(CustomError::MyError(MyError(
nom::Err::Error(CustomError::Static(
"TODO: make this take an owned string so I can dump err.to_string() into it.",
)))
))
})?;
let new_context = context.with_global_settings(&new_settings);
let context = &new_context;

View File

@ -285,9 +285,9 @@ fn priority_cookie(input: OrgSource<'_>) -> Res<OrgSource<'_>, PriorityCookie> {
tag("]"),
))(input)?;
let cookie = PriorityCookie::try_from(priority_character).map_err(|_| {
nom::Err::Error(CustomError::MyError(MyError(
nom::Err::Error(CustomError::Static(
"Failed to cast priority cookie to number.",
)))
))
})?;
Ok((remaining, cookie))
}

View File

@ -162,11 +162,7 @@ fn parse_path_reg<'b, 'g, 'r, 's>(
parser_with_context!(protocol_path_reg)(context),
fuzzy_path_reg,
))(replaced_input)
.map_err(|_| {
nom::Err::Error(CustomError::MyError(MyError(
"No pathreg match after replacement.",
)))
})?;
.map_err(|_| nom::Err::Error(CustomError::Static("No pathreg match after replacement.")))?;
let remaining = input.take(input.len());
let link_type = match link.link_type {
LinkType::Protocol(protocol) => LinkType::Protocol(protocol.into_owned().into()),

View File

@ -200,9 +200,7 @@ fn not_yet_implemented() -> Res<OrgSource<'static>, ()> {
/// Text from the current point until the next line break or end of file
///
/// Useful for debugging.
fn text_until_eol<'r, 's>(
input: OrgSource<'s>,
) -> Result<&'s str, nom::Err<CustomError<OrgSource<'s>>>> {
fn text_until_eol<'r, 's>(input: OrgSource<'s>) -> Result<&'s str, nom::Err<CustomError>> {
let line = recognize(many_till(anychar, alt((line_ending, eof))))(input)
.map(|(_remaining, line)| Into::<&str>::into(line))?;
Ok(line.trim())