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

Adding Errors structure to XmlUtils #1296

Merged
merged 14 commits into from
Jul 29, 2024
Merged

Conversation

marcoag
Copy link
Member

@marcoag marcoag commented Jun 27, 2023

🎉 New feature

Work towards #820.

Summary

Adds missing sdf::Errors structure as an option to report errors on XmlUitls. Makes sure that no errors are printed and all are reported through the structure when using the functions that include it as parameter.

Test it

Call the functions that report sdf::Errors through a parameter and no errors should be printed but only reported through the sdf structure.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Marco A. Gutierrez <[email protected]>
@github-actions github-actions bot added 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic labels Jun 27, 2023
Signed-off-by: Marco A. Gutierrez <[email protected]>
@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Attention: Patch coverage is 86.04651% with 6 lines in your changes missing coverage. Please review.

Project coverage is 87.57%. Comparing base (edd5d0b) to head (ba8af44).
Report is 16 commits behind head on sdf13.

Files Patch % Lines
src/XmlUtils.cc 69.23% 4 Missing ⚠️
src/ParamPassing.cc 92.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            sdf13    #1296      +/-   ##
==========================================
- Coverage   87.58%   87.57%   -0.01%     
==========================================
  Files         128      128              
  Lines       17095    17413     +318     
==========================================
+ Hits        14972    15249     +277     
- Misses       2123     2164      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -179,6 +179,12 @@ namespace sdf

/// \brief Generic error during parsing.
PARSING_ERROR,

/// \brief File not found error.
FILE_NOT_FOUND,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be FILE_NOT_FOUND_ERROR to match the convention of the others?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the interest of not changing enums as much as possible in stable versions, I'd say we should use the FILE_READ error code.

Copy link
Member

Choose a reason for hiding this comment

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

this enum isn't used in this PR; I've opened #1442 targeting #1295 to implement this suggestion

Copy link
Member

Choose a reason for hiding this comment

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

removed in 2bc407d

src/XmlUtils.cc Outdated
@@ -58,10 +74,21 @@ tinyxml2::XMLNode *DeepClone(tinyxml2::XMLDocument *_doc,

/////////////////////////////////////////////////
std::string ElementToString(const tinyxml2::XMLElement *_elem)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test to cover this method?

Copy link
Member

Choose a reason for hiding this comment

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

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 31, 2023
@azeey azeey removed 🎵 harmonic Gazebo Harmonic beta Targeting beta release of upcoming collection labels Aug 26, 2023
@@ -923,7 +923,8 @@ void Converter::Map(tinyxml2::XMLElement *_elem,
/////////////////////////////////////////////////
void Converter::Move(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_moveElem,
const bool _copy)
const bool _copy,
sdf::Errors &_errors)
Copy link
Collaborator

Choose a reason for hiding this comment

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

sdf::Errors should be the first argument to be consistent with the rest of the API.

Copy link
Member

Choose a reason for hiding this comment

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

for whatever reason, the internal APIs in Converter.cc all have the sdf::Errors as the last parameter. So the change in this PR is currently consistent with the rest of the private Converter class APIbut not with the public API. If you want the Converter::Move function to be changed, we can, but I wouldn't want to modify more of the Converter class in this PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm good with maintaining consistency within a class. Let's leave it as is.

src/XmlUtils.cc Outdated
}

/////////////////////////////////////////////////
std::string ElementToString(const tinyxml2::XMLElement *_elem,
Copy link
Collaborator

Choose a reason for hiding this comment

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

sdf::Errors should be the first argument to be consistent with the rest of the API.

Copy link
Member

Choose a reason for hiding this comment

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

src/XmlUtils.hh Outdated
@@ -29,7 +29,7 @@ namespace sdf
// Inline bracket to help doxygen filtering.
inline namespace SDF_VERSION_NAMESPACE {

/// \brief Perform a deep copy of an XML Node
/// \brief Perform a deep copy f an XML Node
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert?

Copy link
Member

Choose a reason for hiding this comment

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

@scpeters
Copy link
Member

scpeters commented Jul 2, 2024

I made a few more changes (see commit messages) and responded to all review comments except the request for tests. I'll come back to this later

scpeters and others added 4 commits July 1, 2024 21:40
* Expect no errors in successful test
* Expect XML_ERROR when passing nullptrs

Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Steve Peters <[email protected]>
@@ -923,7 +923,8 @@ void Converter::Map(tinyxml2::XMLElement *_elem,
/////////////////////////////////////////////////
void Converter::Move(tinyxml2::XMLElement *_elem,
tinyxml2::XMLElement *_moveElem,
const bool _copy)
const bool _copy,
sdf::Errors &_errors)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm good with maintaining consistency within a class. Let's leave it as is.

@scpeters scpeters merged commit fe071fa into sdf13 Jul 29, 2024
11 checks passed
@scpeters scpeters deleted the marcoag/sdf_error_xmlutils branch July 29, 2024 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants