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

jQuery.parseXML should add detailed information about parse errors #4784

Closed
MatthiasSchmalz opened this issue Aug 31, 2020 · 6 comments · Fixed by #4816
Closed

jQuery.parseXML should add detailed information about parse errors #4784

MatthiasSchmalz opened this issue Aug 31, 2020 · 6 comments · Fixed by #4816
Assignees
Milestone

Comments

@MatthiasSchmalz
Copy link

Description

If an invalid XML is passed to jQuery.parseXML, currently the thrown parse error only contain the input data but not the error reason.
However the internally created XML document contains the parser errors in the element parsererror as innerText and could be added. This is helpful for debugging errors in XML files

Link to test case

https://jsfiddle.net/o678xuz3/

@mgol
Copy link
Member

mgol commented Aug 31, 2020

Thanks for the report. However, the test case attached doesn't work, it even doesn't include jQuery. Please share a test case where the issue and what you'd expect instead can be reproduced.

@MatthiasSchmalz
Copy link
Author

I'm sorry I have not described the testcase properly.
It is using jQuery which is available implicitely and it uses the jQuery.parseXML. It logs the error message that is raised by the parser to the console.
Additionally it logs the error which the internally used XML parser produces and which should be returned.

@mgol
Copy link
Member

mgol commented Sep 1, 2020

What do you propose us to change? jQuery.parseXML returns the parsed XML and doesn't crash in case of errors. Do you propose that an error we log to the console contained contents of xml.getElementsByTagName( "parsererror" ) as well?

@MatthiasSchmalz
Copy link
Author

I propose to add the xml.getElementsByTagName( "parsererror" )[0].innerText to the text of the thrown Error.

@timmywil
Copy link
Member

I like this idea. I'd much prefer to either show the parserror content (with provided snippet) or a generic message without trying to add the data to the string.

@timmywil timmywil added Core and removed Needs info labels Oct 26, 2020
@timmywil timmywil added this to the 3.6.0 milestone Oct 26, 2020
@mgol mgol self-assigned this Dec 1, 2020
mgol added a commit to mgol/jquery that referenced this issue Dec 1, 2020
@mgol
Copy link
Member

mgol commented Dec 1, 2020

PR: #4816

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants