gazebosim / sdformat

Simulation Description Format (SDFormat) parser and description files.
http://sdformat.org
Apache License 2.0
166 stars 93 forks source link

More informative parser error messages #146

Open osrf-migration opened 7 years ago

osrf-migration commented 7 years ago

Original report (archived issue) by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


See this question about parser error messages not being very helpful:

http://answers.gazebosim.org/question/15485/tools-to-validate-sdf-files-with/

The error is coming from here:

https://github.com/osrf/sdformat/blob/14daa32dcd3cb86f4b4648d438213479b017dc37/src/parser.cc#L305

Looking at the TinyXml documentation, it looks like there are more functions which we could use to provide a better indication of the error:

http://www.grinninglizard.com/tinyxmldocs/classTiXmlDocument.html

osrf-migration commented 7 years ago

Original comment by clalancette (Bitbucket: clalancette, GitHub: clalancette).


Actually, it is a bit worse than that. We have a number of calls to xml.LoadFile()/xml.Parse() all over the source code, and they all report errors slightly differently. We should probably add a helper function that parses a filename or string, and then prints out a good error message. Then we should use it consistently.