-
Notifications
You must be signed in to change notification settings - Fork 223
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
Broken file raises GPXException, XMLSyntaxError, TypeError #10
Comments
Hi @johnjohndoe thanks for your bug submission. I changed and commited a new version. The parse() method will now fail on invalid XML file and the code where your problem was manifesting is deleted. Also, I deleted the is_valid() method (it there is a exception on parse() -- no need to check is_valid() later). Hope this is OK for you? |
@tkrajina Looks good so far.
If you can accept a crash on an unknown error you could even omit the generic |
What about this: 8accbce ? The idea is to have two kinds of gpxpy exceptions, one for invalid XML files and the other for invalid valid-XML-invalid-GPX files. You can choose if to detect all exceptions with GPXException or XML-specific with GPXXMLSyntaxException. If GPXXMLSyntaxException -- you can retrieve the original (which can be lxml or minidom) exception with e.original_exception. |
@tkrajina I disagree. I find it more complicated to handle multiple |
When I use the parser with a broken GPX file an exception is raised. Here is the code I use. My first assumption was to catch a
GPXException
.However the main reason is somewhere else.
Please refer to this Stackoverflow post which already suggests a solution to the problem.
Here is a sample file that produces the syntax error.
The text was updated successfully, but these errors were encountered: