diff --git a/src/context/context.rs b/src/context/context.rs index 1de2aa58..98ea66df 100644 --- a/src/context/context.rs +++ b/src/context/context.rs @@ -122,7 +122,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> { } } // TODO: Make this a specific error instead of just a generic MyError - return Err(nom::Err::Error(CustomError::MyError(MyError("NoExit")))); + return Err(nom::Err::Error(CustomError::Static("NoExit"))); } /// Indicates if elements should consume the whitespace after them. diff --git a/src/parser/babel_call.rs b/src/parser/babel_call.rs index db50a253..0310505f 100644 --- a/src/parser/babel_call.rs +++ b/src/parser/babel_call.rs @@ -216,9 +216,7 @@ fn impl_balanced_bracket< } if fail_parser(remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( - "Fail parser matched.", - )))); + return Err(nom::Err::Error(CustomError::Static("Fail parser matched."))); } let (remain, _) = anychar(remaining)?; diff --git a/src/parser/citation_reference.rs b/src/parser/citation_reference.rs index 9598707b..9d769f7a 100644 --- a/src/parser/citation_reference.rs +++ b/src/parser/citation_reference.rs @@ -198,9 +198,7 @@ where let pre_bracket_depth = input.get_bracket_depth(); let (remaining, output) = inner(input)?; if remaining.get_bracket_depth() - pre_bracket_depth != 0 { - return Err(nom::Err::Error(CustomError::MyError(MyError( - "UnbalancedBrackets", - )))); + return Err(nom::Err::Error(CustomError::Static("UnbalancedBrackets"))); } Ok((remaining, output)) } diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 828dbf7f..7523037a 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -34,9 +34,9 @@ pub(crate) fn comment<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, Comment<'s>> { if immediate_in_section(context, "comment") { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } let parser_context = ContextElement::Context("comment"); let parser_context = context.with_additional_node(&parser_context); diff --git a/src/parser/drawer.rs b/src/parser/drawer.rs index 9d1dbfdd..d440f54c 100644 --- a/src/parser/drawer.rs +++ b/src/parser/drawer.rs @@ -47,9 +47,9 @@ where AK: IntoIterator>, { if immediate_in_section(context, "drawer") { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } start_of_line(remaining)?; let (remaining, _leading_whitespace) = space0(remaining)?; diff --git a/src/parser/dynamic_block.rs b/src/parser/dynamic_block.rs index c170acbf..9a8e1cbc 100644 --- a/src/parser/dynamic_block.rs +++ b/src/parser/dynamic_block.rs @@ -53,9 +53,9 @@ where AK: IntoIterator>, { if immediate_in_section(context, "dynamic block") { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } start_of_line(remaining)?; diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index ca553ee7..5cf47290 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -250,9 +250,7 @@ fn _element<'b, 'g, 'r, 's>( ); } - Err(nom::Err::Error(CustomError::MyError(MyError( - "No element.", - )))) + Err(nom::Err::Error(CustomError::Static("No element."))) } pub(crate) const fn detect_element( @@ -322,7 +320,5 @@ fn _detect_element<'b, 'g, 'r, 's>( return Ok((input, ())); } - Err(nom::Err::Error(CustomError::MyError(MyError( - "No element detected.", - )))) + Err(nom::Err::Error(CustomError::Static("No element detected."))) } diff --git a/src/parser/entity.rs b/src/parser/entity.rs index 3ae04720..57ce58a3 100644 --- a/src/parser/entity.rs +++ b/src/parser/entity.rs @@ -68,7 +68,7 @@ fn name<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError("NoEntity")))) + Err(nom::Err::Error(CustomError::Static("NoEntity"))) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] diff --git a/src/parser/footnote_definition.rs b/src/parser/footnote_definition.rs index f447def0..e263c178 100644 --- a/src/parser/footnote_definition.rs +++ b/src/parser/footnote_definition.rs @@ -47,9 +47,9 @@ where AK: IntoIterator>, { if immediate_in_section(context, "footnote definition") { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } start_of_line(remaining)?; // Cannot be indented. diff --git a/src/parser/footnote_reference.rs b/src/parser/footnote_reference.rs index 76db35bc..2823ad7c 100644 --- a/src/parser/footnote_reference.rs +++ b/src/parser/footnote_reference.rs @@ -175,9 +175,9 @@ fn _footnote_definition_end<'b, 'g, 'r, 's>( let current_depth = input.get_bracket_depth() - starting_bracket_depth; if current_depth > 0 { // Its impossible for the next character to end the footnote reference definition if we're any amount of brackets deep - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "NoFootnoteReferenceDefinitionEnd", - )))); + ))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing bracket should end the footnote definition. diff --git a/src/parser/greater_block.rs b/src/parser/greater_block.rs index 5e8af148..4fd3d721 100644 --- a/src/parser/greater_block.rs +++ b/src/parser/greater_block.rs @@ -234,9 +234,9 @@ fn greater_block_body<'c, 'b, 'g, 'r, 's>( return Err(CustomError::Static( "Cannot nest objects of the same element", )); - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } let exit_with_name = greater_block_end(name); let (remaining, _nl) = tuple((space0, line_ending))(input)?; diff --git a/src/parser/headline.rs b/src/parser/headline.rs index 25663d14..ea98acc5 100644 --- a/src/parser/headline.rs +++ b/src/parser/headline.rs @@ -274,9 +274,7 @@ fn heading_keyword<'b, 'g, 'r, 's>( return Ok((remaining, (TodoKeywordType::Done, ent))); } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoTodoKeyword", - )))) + Err(nom::Err::Error(CustomError::Static("NoTodoKeyword"))) } } diff --git a/src/parser/inline_babel_call.rs b/src/parser/inline_babel_call.rs index a87cc7c4..f059da05 100644 --- a/src/parser/inline_babel_call.rs +++ b/src/parser/inline_babel_call.rs @@ -130,9 +130,7 @@ fn _header_end<'b, 'g, 'r, 's>( let current_depth = input.get_bracket_depth() - starting_bracket_depth; if current_depth > 0 { // Its impossible for the next character to end the header if we're any amount of bracket deep - return Err(nom::Err::Error(CustomError::MyError(MyError( - "NoHeaderEnd", - )))); + return Err(nom::Err::Error(CustomError::Static("NoHeaderEnd"))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing bracket should end the header. @@ -182,9 +180,7 @@ fn _argument_end<'b, 'g, 'r, 's>( let current_depth = input.get_parenthesis_depth() - starting_parenthesis_depth; if current_depth > 0 { // Its impossible for the next character to end the argument if we're any amount of parenthesis deep - return Err(nom::Err::Error(CustomError::MyError(MyError( - "NoArgumentEnd", - )))); + return Err(nom::Err::Error(CustomError::Static("NoArgumentEnd"))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing parenthesis should end the argument. diff --git a/src/parser/inline_source_block.rs b/src/parser/inline_source_block.rs index 0611cb98..f0e22a7c 100644 --- a/src/parser/inline_source_block.rs +++ b/src/parser/inline_source_block.rs @@ -124,9 +124,7 @@ fn _header_end<'b, 'g, 'r, 's>( let current_depth = input.get_bracket_depth() - starting_bracket_depth; if current_depth > 0 { // Its impossible for the next character to end the header if we're any amount of bracket deep - return Err(nom::Err::Error(CustomError::MyError(MyError( - "NoHeaderEnd", - )))); + return Err(nom::Err::Error(CustomError::Static("NoHeaderEnd"))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing bracket should end the header. @@ -186,7 +184,7 @@ fn _body_end<'b, 'g, 'r, 's>( let current_depth = input.get_brace_depth() - starting_brace_depth; if current_depth > 0 { // Its impossible for the next character to end the body if we're any amount of brace deep - return Err(nom::Err::Error(CustomError::MyError(MyError("NoBodyEnd")))); + return Err(nom::Err::Error(CustomError::Static("NoBodyEnd"))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing brace should end the body. diff --git a/src/parser/keyword.rs b/src/parser/keyword.rs index b9445fb8..e19c4e9d 100644 --- a/src/parser/keyword.rs +++ b/src/parser/keyword.rs @@ -151,9 +151,7 @@ fn affiliated_key<'b, 'g, 'r, 's>( element!(dual_affiliated_key, context, input); element!(plain_affiliated_key, context, input); element!(export_keyword, input); - Err(nom::Err::Error(CustomError::MyError(MyError( - "No affiliated key.", - )))) + Err(nom::Err::Error(CustomError::Static("No affiliated key."))) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -174,9 +172,7 @@ fn plain_affiliated_key<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoKeywordKey", - )))) + Err(nom::Err::Error(CustomError::Static("NoKeywordKey"))) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] @@ -197,9 +193,7 @@ fn dual_affiliated_key<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoKeywordKey", - )))) + Err(nom::Err::Error(CustomError::Static("NoKeywordKey"))) } #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] diff --git a/src/parser/latex_fragment.rs b/src/parser/latex_fragment.rs index 6febdcfb..e4ade8a1 100644 --- a/src/parser/latex_fragment.rs +++ b/src/parser/latex_fragment.rs @@ -208,9 +208,9 @@ fn pre<'b, 'g, 'r, 's>( ) -> Res, ()> { let preceding_character = input.get_preceding_character(); if let Some('$') = preceding_character { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre character for dollar char fragment.", - )))); + ))); } Ok((input, ())) } @@ -282,9 +282,9 @@ fn close_border<'b, 'g, 'r, 's>( match preceding_character { Some(c) if !c.is_whitespace() && !".,;$".contains(c) => Ok((input, ())), _ => { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre character for dollar char fragment.", - )))); + ))); } } } diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index 91aa6b76..9f99289e 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -603,7 +603,7 @@ fn _example_src_switches<'s>( } } if !matched_a_word { - return Err(nom::Err::Error(CustomError::MyError(MyError("No words.")))); + return Err(nom::Err::Error(CustomError::Static("No words."))); } let remaining = last_match_remaining; diff --git a/src/parser/line_break.rs b/src/parser/line_break.rs index 5e1dc065..f23e5253 100644 --- a/src/parser/line_break.rs +++ b/src/parser/line_break.rs @@ -44,9 +44,9 @@ fn pre<'b, 'g, 'r, 's>( match preceding_character { // If None, we are at the start of the file None | Some('\\') => { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre character for line break.", - )))); + ))); } _ => {} }; @@ -54,9 +54,9 @@ fn pre<'b, 'g, 'r, 's>( let current_line = input.text_since_line_break(); let is_non_empty_line = current_line.chars().any(|c| !c.is_whitespace()); if !is_non_empty_line { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre line for line break.", - )))); + ))); } Ok((input, ())) diff --git a/src/parser/object_parser.rs b/src/parser/object_parser.rs index 5603a35b..c7e15d99 100644 --- a/src/parser/object_parser.rs +++ b/src/parser/object_parser.rs @@ -42,7 +42,7 @@ pub(crate) fn standard_set_object<'b, 'g, 'r, 's>( input, Object::PlainText ); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -60,7 +60,7 @@ pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>( input, Object::PlainText ); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -102,7 +102,7 @@ fn standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( element!(angle_link, context, input, Object::AngleLink); element!(org_macro, context, input, Object::OrgMacro); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -118,7 +118,7 @@ fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( element!(entity, context, input, Object::Entity); element!(latex_fragment, context, input, Object::LatexFragment); element!(text_markup, context, input); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -136,9 +136,7 @@ pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( return Ok((input, ())); } - return Err(nom::Err::Error(CustomError::MyError(MyError( - "No object detected.", - )))); + return Err(nom::Err::Error(CustomError::Static("No object detected."))); } #[cfg_attr( @@ -156,9 +154,7 @@ fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>( return Ok((input, ())); } - return Err(nom::Err::Error(CustomError::MyError(MyError( - "No object detected.", - )))); + return Err(nom::Err::Error(CustomError::Static("No object detected."))); } #[cfg_attr( @@ -181,7 +177,7 @@ pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>( input, Object::PlainText ); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -204,7 +200,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( element!(inline_babel_call, context, input, Object::InlineBabelCall); element!(org_macro, context, input, Object::OrgMacro); element!(minimal_set_object_sans_plain_text, context, input); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -222,9 +218,7 @@ fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( return Ok((input, ())); } - Err(nom::Err::Error(CustomError::MyError(MyError( - "No object detected.", - )))) + Err(nom::Err::Error(CustomError::Static("No object detected."))) } #[cfg_attr( @@ -242,7 +236,7 @@ pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>( input, Object::PlainText ); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -270,7 +264,7 @@ fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( element!(target, context, input, Object::Target); element!(timestamp, context, input, Object::Timestamp); element!(minimal_set_object_sans_plain_text, context, input); - Err(nom::Err::Error(CustomError::MyError(MyError("No object.")))) + Err(nom::Err::Error(CustomError::Static("No object."))) } #[cfg_attr( @@ -288,7 +282,5 @@ fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( return Ok((input, ())); } - return Err(nom::Err::Error(CustomError::MyError(MyError( - "No object detected.", - )))); + return Err(nom::Err::Error(CustomError::Static("No object detected."))); } diff --git a/src/parser/plain_link.rs b/src/parser/plain_link.rs index f6fec5e3..677b8640 100644 --- a/src/parser/plain_link.rs +++ b/src/parser/plain_link.rs @@ -94,9 +94,9 @@ fn pre<'b, 'g, 'r, 's>( Some(x) if !WORD_CONSTITUENT_CHARACTERS.contains(x) => {} Some(_) => { // Not at start of line, cannot be a heading - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre character for plain link.", - )))); + ))); } }; Ok((input, ())) @@ -267,9 +267,7 @@ pub(crate) fn protocol<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoLinkProtocol", - )))) + Err(nom::Err::Error(CustomError::Static("NoLinkProtocol"))) } #[cfg_attr( @@ -341,9 +339,7 @@ fn impl_path_plain_end<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "No path plain end", - )))) + Err(nom::Err::Error(CustomError::Static("No path plain end"))) } #[cfg_attr( @@ -430,7 +426,7 @@ fn _path_plain_parenthesis_end<'s>( return open_parenthesis; } } - Err(nom::Err::Error(CustomError::MyError(MyError( + Err(nom::Err::Error(CustomError::Static( "No closing parenthesis", - )))) + ))) } diff --git a/src/parser/plain_list.rs b/src/parser/plain_list.rs index 4829d566..4ffef253 100644 --- a/src/parser/plain_list.rs +++ b/src/parser/plain_list.rs @@ -77,9 +77,7 @@ where { return Ok((input, ())); } - return Err(nom::Err::Error(CustomError::MyError(MyError( - "No element detected.", - )))); + return Err(nom::Err::Error(CustomError::Static("No element detected."))); } #[cfg_attr( @@ -151,9 +149,9 @@ where let (final_child_start, _final_item_first_parse) = match children.pop() { Some(final_child) => final_child, None => { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Plain lists require at least one element.", - )))); + ))); } }; let final_item_context = ContextElement::ConsumeTrailingWhitespace(false); diff --git a/src/parser/plain_text.rs b/src/parser/plain_text.rs index 6cc1915b..5cb9aeb5 100644 --- a/src/parser/plain_text.rs +++ b/src/parser/plain_text.rs @@ -117,9 +117,9 @@ impl<'x> RematchObject<'x> for PlainText<'x> { continue; } - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Target does not match.", - )))); + ))); } let source = get_consumed(input, remaining); diff --git a/src/parser/property_drawer.rs b/src/parser/property_drawer.rs index 284ceb58..5cf4d02a 100644 --- a/src/parser/property_drawer.rs +++ b/src/parser/property_drawer.rs @@ -38,9 +38,9 @@ pub(crate) fn property_drawer<'b, 'g, 'r, 's>( input: OrgSource<'s>, ) -> Res, PropertyDrawer<'s>> { if immediate_in_section(context, "property-drawer") { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Cannot nest objects of the same element", - )))); + ))); } let ( remaining, diff --git a/src/parser/radio_link.rs b/src/parser/radio_link.rs index 888efafc..03b27eb2 100644 --- a/src/parser/radio_link.rs +++ b/src/parser/radio_link.rs @@ -51,9 +51,7 @@ pub(crate) fn radio_link<'b, 'g, 'r, 's>( )); } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "NoRadioLink", - )))) + Err(nom::Err::Error(CustomError::Static("NoRadioLink"))) } #[cfg_attr( @@ -97,9 +95,9 @@ pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>( new_matches.push(new_match); } _ => { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "OnlyMinimalSetObjectsAllowed", - )))); + ))); } }; } diff --git a/src/parser/regular_link.rs b/src/parser/regular_link.rs index d509611d..244e6d88 100644 --- a/src/parser/regular_link.rs +++ b/src/parser/regular_link.rs @@ -482,7 +482,5 @@ fn impl_path_reg_end<'b, 'g, 'r, 's>( } } - Err(nom::Err::Error(CustomError::MyError(MyError( - "No path reg end", - )))) + Err(nom::Err::Error(CustomError::Static("No path reg end"))) } diff --git a/src/parser/subscript_and_superscript.rs b/src/parser/subscript_and_superscript.rs index 1d695908..a18a787f 100644 --- a/src/parser/subscript_and_superscript.rs +++ b/src/parser/subscript_and_superscript.rs @@ -231,9 +231,9 @@ fn _script_with_braces_end<'b, 'g, 'r, 's>( let current_depth = input.get_brace_depth() - starting_brace_depth; if current_depth > 0 { // Its impossible for the next character to end the subscript or superscript if we're any amount of braces deep - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid end for subscript or superscript.", - )))); + ))); } if current_depth < 0 { // This shouldn't be possible because if depth is 0 then a closing brace should end the subscript or superscript. @@ -286,7 +286,7 @@ fn _script_with_parenthesis_end<'s>( return close_parenthesis; } } - Err(nom::Err::Error(CustomError::MyError(MyError( + Err(nom::Err::Error(CustomError::Static( "No script parenthesis end.", - )))) + ))) } diff --git a/src/parser/target.rs b/src/parser/target.rs index f139b666..d91fa2ff 100644 --- a/src/parser/target.rs +++ b/src/parser/target.rs @@ -41,9 +41,9 @@ pub(crate) fn target<'b, 'g, 'r, 's>( .get_preceding_character() .expect("We cannot be at the start of the file because we are inside a target."); if preceding_character.is_whitespace() { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Targets cannot end with whitespace.", - )))); + ))); } let (remaining, _) = tag(">>")(remaining)?; let (remaining, _trailing_whitespace) = diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index 7f02b93a..cdb17638 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -233,9 +233,9 @@ fn _text_markup_object<'b, 'g, 'r, 's, 'c>( #[cfg(feature = "tracing")] let _enter = span.enter(); if exit_matcher_parser(context, remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Parent exit matcher is triggering.", - )))); + ))); } } @@ -289,9 +289,9 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>( #[cfg(feature = "tracing")] let _enter = span.enter(); if exit_matcher_parser(context, remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Parent exit matcher is triggering.", - )))); + ))); } } @@ -320,9 +320,9 @@ fn pre<'b, 'g, 'r, 's>( // If None, we are at the start of the file which is technically the beginning of a line. Some('-') | Some('(') | Some('{') | Some('\'') | Some('"') => {} Some(_) => { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Not a valid pre character for text markup.", - )))); + ))); } None => unreachable!(), // None is for start of file, which should already be handled by the start_of_line matcher above. }; @@ -359,9 +359,9 @@ fn _text_markup_end<'b, 'g, 'r, 's, 'c>( contents_start_offset: usize, ) -> Res, OrgSource<'s>> { if input.get_byte_offset() == contents_start_offset { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Text markup cannot be empty", - )))); + ))); } not(preceded_by_whitespace(false))(input)?; let (remaining, _marker) = terminated( @@ -494,9 +494,9 @@ fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>( #[cfg(feature = "tracing")] let _enter = span.enter(); if exit_matcher_parser(context, remaining).is_ok() { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Parent exit matcher is triggering.", - )))); + ))); } } diff --git a/src/parser/util.rs b/src/parser/util.rs index f80e1df4..123adfe3 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -128,9 +128,7 @@ pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res, ()> if input.is_at_start_of_line() { Ok((input, ())) } else { - Err(nom::Err::Error(CustomError::MyError(MyError( - "Not at start of line", - )))) + Err(nom::Err::Error(CustomError::Static("Not at start of line"))) } } @@ -151,9 +149,9 @@ fn _preceded_by_whitespace<'s>( .map(|c| c.is_whitespace() || c == '\u{200B}') // 200B = Zero-width space .unwrap_or(allow_start_of_file) { - return Err(nom::Err::Error(CustomError::MyError(MyError( + return Err(nom::Err::Error(CustomError::Static( "Must be preceded by a whitespace character.", - )))); + ))); } Ok((input, ())) } @@ -194,9 +192,7 @@ pub(crate) fn text_until_exit<'b, 'g, 'r, 's>( #[allow(dead_code)] fn not_yet_implemented() -> Res, ()> { - Err(nom::Err::Error(CustomError::MyError(MyError( - "Not implemented yet.", - )))) + Err(nom::Err::Error(CustomError::Static("Not implemented yet."))) } #[allow(dead_code)]