-
Notifications
You must be signed in to change notification settings - Fork 95
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
Converter: add sdf::Errors output to API methods #1123
Conversation
src/CMakeLists.txt
Outdated
XmlUtils.cc | ||
Utils.cc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alphabetize
XmlUtils.cc | |
Utils.cc) | |
Utils.cc | |
XmlUtils.cc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 5612619.
src/Converter.hh
Outdated
/// \param[in] _toVersion Version number in string format | ||
/// \param[in] _quiet False to be more verbose | ||
/// \param[in] _toVersion Version number in string format. | ||
/// \param[out] _errors Vector of errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels a little weird to put an output variable in the middle of the argument list. I think I favor either making output variables the first argument (like SemanticPose::Resolve) so that subsequent input parameters could be optional.
Also, we sometimes pass Errors
by reference and sometimes return from the function. It feels weird to both return bool
and write to an Errors
vector though.
@azeey what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels a little weird to put an output variable in the middle of the argument list. I think I favor either making output variables the first argument (like SemanticPose::Resolve) so that subsequent input parameters could be optional.
Sounds good to me, will apply the changes on this PR.
Also, we sometimes pass
Errors
by reference and sometimes return from the function. It feels weird to both returnbool
and write to anErrors
vector though.
This seems a bit more tricky since not all the time an error is added to the structure false
is returned, meaning errors.empty() != return false
, so I'm not sure if there would be trivial way of checking this without changing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized, shall we make the ParserConfig
also optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is an internal function, I recommend against making ParserConfig
optional. Whoever is calling should be passing a config.
Codecov Report
@@ Coverage Diff @@
## sdf13 #1123 +/- ##
==========================================
- Coverage 87.53% 87.20% -0.33%
==========================================
Files 124 124
Lines 16144 16216 +72
==========================================
+ Hits 14131 14141 +10
- Misses 2013 2075 +62
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
cdf6c6e
to
7ab807e
Compare
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
7ab807e
to
ecb8fa2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some suggestions on how the new APIs in parser.hh should be structured. The Converter.hh APIs are not public, so they are not as critical
src/Converter.cc
Outdated
ss << "Unknown convert element[" | ||
<< name | ||
<< "]"; | ||
_errors.push_back({ErrorCode::FATAL_ERROR, ss.str()}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is a fatal error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not, switched to CONVERSION_ERROR
in 5f91d45.
include/sdf/parser.hh
Outdated
/// \param[out] _errors Vector of errors. | ||
/// \return True on success. | ||
SDFORMAT_VISIBLE | ||
bool convertFile(const std::string &_filename, const std::string &_version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a TODO to deprecate the other overloads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean to deprecate all overloads that we are creating for the error reporting right? where would you say we should put this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. We should definitely create a ticket for it, but I'm not sure we'll remember to check, so I suggest putting a TODO in at least one of these files (probably parser.hh since it's more frequently updated/looked at)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
Signed-off-by: Marco A. Gutierrez <marco@openrobotics.org>
This returns Errors instead of bool and makes the SDFPtr the first argument. Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Marco A. Gutierrez marco@openrobotics.org
🎉 New feature
Work towards #820.
Summary
It moves all error reporting in the
Converter
class tosdf::Errors
. It also includes minimal changes to the parser so theConverter
changes can compile and work adequately. A full update to addsdf::Errors
support to the parser will follow up on a separate PR so this one is not to big.After this PR is merged the parser might introduce more errors into the
sdf::Errors
structure than before. In order to reduce the time this behavior is changed it is recommended to wait until the PR that addresses errors on the parser is ready so it can be merged immediately after this one.There is one warning that is still printed unless the warnings policy is set to
sdf::EnforcementPolicy::ERR
.Test it
Using any method of the
Converter
class should only print warnings and report all errors throughsdf::Errors
. If the warnings policy is set tosdf::EnforcementPolicy::ERR
warnings should be reported also in thesdf::Errors
structure.Checklist
codecheck
passed (See contributing)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.