Skip to content

Stack empty error with incorrect or missing verse numbers #363

@pmachapman

Description

@pmachapman

GetRows fails with the following error:

Message: 
System.InvalidOperationException : An error occurred while parsing the text 'MAT'. Verse: MAT 1:१, line: 6, character: 1, error: 'Stack empty.'
  ----> System.InvalidOperationException : Stack empty.

  Stack Trace: 
UsfmTextBase.GetVersesInDocOrder() line 75
ScriptureText.GetRows() line 21
UsfmMemoryTextTests.GetRows(String usfm, Boolean includeMarkers, Boolean includeAllText) line 460
UsfmMemoryTextTests.GetRows_VersePara_BeginningNonVerseSegment2() line 186
RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
--InvalidOperationException
Stack`1.ThrowForEmptyStack()
Stack`1.Pop()
ScriptureRefUsfmParserHandlerBase.NextElement(String marker) line 334
ScriptureRefUsfmParserHandlerBase.StartParentElement(String marker) line 340
ScriptureRefUsfmParserHandlerBase.EndPara(UsfmParserState state, String marker) line 136
UsfmParser.CloseElement(Boolean closed) line 639
UsfmParser.CloseAll() line 592
UsfmParser.ProcessToken() line 145
UsfmParser.ProcessTokens() line 133
UsfmTextBase.GetVersesInDocOrder() line 65

Given USFM with non-latin numbers:

\id MAT - Test
\c 1
\p
\v १
\v 3,৪ Verse 3,4
\p
\p
\v 1,२ text
\pi1 text
\v 3 text

Or when the \v tag is empty:

\id MAT - Test
\c 1
\p
\v
\b
\c 1
\s heading text
\v  \vn 1 verse text
\c 28
\p
\v
\p
\v
\p
\v
\p
\c 15
\v
\s heading text goes here

Or when the verse is invalid:

\c 1
\v BK1 text goes here
\v BK 2 text goes here
\v BK 3 text goes here
\v BK 4 text goes here

Or the verse range is incomplete:

\c 1
\s text goes here
\p
\q1
\v 1,
\q1 text goes here

Or a space is missing between the verse number and the verse text:

\c 12 Text goes here
\s Heading goes here
\sp
\q
\v 1«Text goes here
\q Text goes here
\q

Or some kind of user error:

\c 24 verse 0 text
\v 1, verse 1 text
\v 2, verse 2 text 3, verse 3 text 4, verse 4 text

What should probably happen is either the verse is ignored, or an error about the verse number being incorrect is thrown so that it can be corrected in the USFM.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

👀 In review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions