Skip to content

Improve XML parse error reporting#2420

Merged
mzagozen merged 2 commits into
mainfrom
xml-runtime-error
Aug 18, 2025
Merged

Improve XML parse error reporting#2420
mzagozen merged 2 commits into
mainfrom
xml-runtime-error

Conversation

@mzagozen

Copy link
Copy Markdown
Collaborator

Use xmlGetLastError() to get the last error from libxml2. Strip trailing whitespace from the message if present.

We already get more verbose output from libxml2 on stderr, but this allows us to pass at least some hints about what went wrong via an exception.

Comment thread base/src/xml.ext.c Outdated
Use xmlGetLastError() to get the last error from libxml2. Strip trailing
whitespace from the message if present. Suppres verbose output from
libxml2 on stderr with the XML_PARSE_NOERROR option.

@plajjan plajjan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust that this works. Consider taking the opportunity to change the error type to something better and perhaps add a test case or two (that would go in tests/stdlib_tests/src/test_xml.xml).

Feel free to merge. If you want to merge as-is, that's OK. If you want to add the test and / or change exception type, that's OK too.

Comment thread base/src/xml.ext.c Outdated
@mzagozen mzagozen enabled auto-merge August 18, 2025 08:00
Comment thread base/src/xml.act Outdated
Comment thread base/src/xml.ext.c Outdated
The XmlParseError base exception is ValueError, but it includes more
context information about the error location.
@mzagozen mzagozen merged commit 5f186df into main Aug 18, 2025
40 of 41 checks passed
@mzagozen mzagozen deleted the xml-runtime-error branch August 18, 2025 09:16
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