Continue removing MyError.
This commit is contained in:
parent
c9d7251e3b
commit
77e6c22ad8
@ -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.
|
||||
|
@ -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)?;
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ pub(crate) fn comment<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, 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);
|
||||
|
@ -47,9 +47,9 @@ where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
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)?;
|
||||
|
@ -53,9 +53,9 @@ where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
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)?;
|
||||
|
@ -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.")))
|
||||
}
|
||||
|
@ -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"))]
|
||||
|
@ -47,9 +47,9 @@ where
|
||||
AK: IntoIterator<Item = Keyword<'s>>,
|
||||
{
|
||||
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.
|
||||
|
@ -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.
|
||||
|
@ -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)?;
|
||||
|
@ -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")))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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"))]
|
||||
|
@ -208,9 +208,9 @@ fn pre<'b, 'g, 'r, 's>(
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
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.",
|
||||
))));
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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, ()))
|
||||
|
@ -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.")));
|
||||
}
|
||||
|
@ -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",
|
||||
))))
|
||||
)))
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -38,9 +38,9 @@ pub(crate) fn property_drawer<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, 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,
|
||||
|
@ -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",
|
||||
))));
|
||||
)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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")))
|
||||
}
|
||||
|
@ -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.",
|
||||
))))
|
||||
)))
|
||||
}
|
||||
|
@ -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) =
|
||||
|
@ -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>, 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.",
|
||||
))));
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,9 +128,7 @@ pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()>
|
||||
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<OrgSource<'static>, ()> {
|
||||
Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Not implemented yet.",
|
||||
))))
|
||||
Err(nom::Err::Error(CustomError::Static("Not implemented yet.")))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user