Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up parser error handling #473

Merged
merged 2 commits into from
Nov 29, 2023
Merged

Conversation

jacksonj04
Copy link
Collaborator

Review and merge #472 first!

Remove some unnecessary abstraction in how we identify if a document has failed to parse. At the same time, stop swallowing where a document is not XML (which should never happen) and fail hard with a specific exception instead.

@jacksonj04 jacksonj04 force-pushed the chore/clean-up-parser-error-handling branch from fd98518 to 06d2f0e Compare November 28, 2023 23:50
@dragon-dxw dragon-dxw force-pushed the chore/clean-up-parser-error-handling branch from 06d2f0e to 7d99d04 Compare November 29, 2023 12:15
This is only ever used in one place; to get the root element of the XML
of a document. To help simplify understanding, move it into the scope of
the `Document` class.

Signed-off-by: David McKee <[email protected]>
The code to extract the root element of the XML is also responsible for
identifying where a document is not XML (which is theoretically
possible; MarkLogic can also store JSON, blobs and text). At the moment
if this happens the fact it's not XML is silently swallowed and we
pretend the root element is `error`, the same as a parser failure.

This behaviour could potentially mask other problems; if we encounter a
parser error then although it's unwanted it's a defined condition which
we want to be able to handle within the usual user flows. Encountering a
non-XML document means something has gone catastrophically wrong, and we
want things to fail hard and shout about it.

Signed-off-by: David McKee <[email protected]>
@dragon-dxw dragon-dxw force-pushed the chore/clean-up-parser-error-handling branch from 7d99d04 to 6b157d6 Compare November 29, 2023 12:26
@jacksonj04 jacksonj04 merged commit b8a53cc into main Nov 29, 2023
9 checks passed
@jacksonj04 jacksonj04 deleted the chore/clean-up-parser-error-handling branch November 29, 2023 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants