robotology / idyntree

Multibody Dynamics Library designed for Free Floating Robots
BSD 3-Clause "New" or "Revised" License
156 stars 65 forks source link

Add basic error handling in the XML parser. #1053

Closed francesco-romano closed 1 year ago

francesco-romano commented 1 year ago

Currently the only error returned by the parser is for invalid or not well format XML where the parser itself will fail. For any other "semantic" validation there is no way to return an error to the caller, just prints to stderr.

One option could of course being to return all parsed data and do a validation after but this would implies some changes and keeping track of discarded parsed text.

This change introduces a simple state that is propagated to all parser elements. The state is currently a simple bool, enough to report an error but can be easily extended if needed.

The code has a lot of TODOs where to put error notification. Currently this change reports only an error in case two joints are named the same, and a test has been added to verify it.

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

traversaro commented 1 year ago

Thanks @francesco-romano ! Please:

francesco-romano commented 1 year ago

Done

traversaro commented 1 year ago

Thanks!