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( pub(crate) fn check_exit_matcher(
&'r self, &'r self,
i: OrgSource<'s>, i: OrgSource<'s>,
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> { ) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError> {
let mut current_class_filter = ExitClass::Gamma; let mut current_class_filter = ExitClass::Gamma;
for current_node in self.iter_context() { for current_node in self.iter_context() {
let context_element = current_node.get_data(); 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". /// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
#[allow(dead_code)] #[allow(dead_code)]
fn document<'s>(context: RefContext<'_, '_, '_, 's>, input: &'s str) -> Res<&'s str, Document<'s>> { 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)) Ok((Into::<&str>::into(remaining), doc))
} }
@ -132,9 +132,9 @@ fn document_org_source<'b, 'g, 'r, 's>(
let (_, setup_file_settings) = let (_, setup_file_settings) =
scan_for_in_buffer_settings(setup_file.into()).map_err(|err| { scan_for_in_buffer_settings(setup_file.into()).map_err(|err| {
eprintln!("{}", 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.", "TODO: make this take an owned string so I can dump err.to_string() into it.",
))) ))
})?; })?;
final_settings.extend(setup_file_settings); 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()) let new_settings = apply_in_buffer_settings(final_settings, context.get_global_settings())
.map_err(|err| { .map_err(|err| {
eprintln!("{}", 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.", "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 new_context = context.with_global_settings(&new_settings);
let context = &new_context; let context = &new_context;

View File

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

View File

@ -162,11 +162,7 @@ fn parse_path_reg<'b, 'g, 'r, 's>(
parser_with_context!(protocol_path_reg)(context), parser_with_context!(protocol_path_reg)(context),
fuzzy_path_reg, fuzzy_path_reg,
))(replaced_input) ))(replaced_input)
.map_err(|_| { .map_err(|_| nom::Err::Error(CustomError::Static("No pathreg match after replacement.")))?;
nom::Err::Error(CustomError::MyError(MyError(
"No pathreg match after replacement.",
)))
})?;
let remaining = input.take(input.len()); let remaining = input.take(input.len());
let link_type = match link.link_type { let link_type = match link.link_type {
LinkType::Protocol(protocol) => LinkType::Protocol(protocol.into_owned().into()), 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 /// Text from the current point until the next line break or end of file
/// ///
/// Useful for debugging. /// Useful for debugging.
fn text_until_eol<'r, 's>( fn text_until_eol<'r, 's>(input: OrgSource<'s>) -> Result<&'s str, nom::Err<CustomError>> {
input: OrgSource<'s>,
) -> Result<&'s str, nom::Err<CustomError<OrgSource<'s>>>> {
let line = recognize(many_till(anychar, alt((line_ending, eof))))(input) let line = recognize(many_till(anychar, alt((line_ending, eof))))(input)
.map(|(_remaining, line)| Into::<&str>::into(line))?; .map(|(_remaining, line)| Into::<&str>::into(line))?;
Ok(line.trim()) Ok(line.trim())