-
Notifications
You must be signed in to change notification settings - Fork 100
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
Make throwOrPrintErrors a member of sdf::Error #1220
Conversation
Signed-off-by: Marco A. Gutierrez <[email protected]>
Codecov Report
@@ Coverage Diff @@
## sdf13 #1220 +/- ##
=======================================
Coverage 87.20% 87.20%
=======================================
Files 124 124
Lines 16229 16232 +3
=======================================
+ Hits 14152 14155 +3
Misses 2077 2077
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
quick nit: Since the title of the PR becomes part of the changelog, mind changing the tense to match the rest of the changelog? We commonly use imperative ("Move throwOrPrintErrors...") or past tense ("Moved throwOrPrintErrors...")
include/sdf/Error.hh
Outdated
@@ -247,6 +247,10 @@ namespace sdf | |||
/// \sa Element::SetXmlPath | |||
public: void SetXmlPath(const std::string &_xmlPath); | |||
|
|||
/// \brief It will print the error to sdferr or throw it using | |||
/// SDF_ASSERT depending on its ErrorCode. | |||
public: void throwOrPrintError(); |
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.
If it's a member function, the first letter should be uppercase.
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 f6f1715.
include/sdf/Error.hh
Outdated
@@ -247,6 +247,10 @@ namespace sdf | |||
/// \sa Element::SetXmlPath | |||
public: void SetXmlPath(const std::string &_xmlPath); | |||
|
|||
/// \brief It will print the error to sdferr or throw it using | |||
/// SDF_ASSERT depending on its ErrorCode. | |||
public: void throwOrPrintError(); |
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 it's not modifying anything, it should be a const
function
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.
True, done in 6483e3a.
src/Utils.cc
Outdated
@@ -167,18 +167,11 @@ void enforceConfigurablePolicyCondition( | |||
} | |||
|
|||
///////////////////////////////////////////////// | |||
void throwOrPrintErrors(const sdf::Errors& _errors) | |||
void throwOrPrintErrors(sdf::Errors& _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.
Shouldn't have to make this change if the member function is const
.
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.
Changed back in 6483e3a.
src/Error.cc
Outdated
@@ -118,6 +120,19 @@ void Error::SetXmlPath(const std::string &_xmlPath) | |||
this->dataPtr->xmlPath = _xmlPath; | |||
} | |||
|
|||
///////////////////////////////////////////////// | |||
void Error::throwOrPrintError() |
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 think it would be a good idea for this to take an ostream
object as input so it can be used with sdfwarn
and others.
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.
sdferr
and sdfwarn
seem to be ConsoleStream
shall it take that one as input instead of the ostream
?
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.
Added a ConsoleStream
for now in 6483e3a. Let me know if we should do something different.
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.
Yeah, I thought ConsoleStream
inherited from ostream
, but that's not the case, so what you have is good.
Signed-off-by: Marco A. Gutierrez <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
src/Error.cc
Outdated
@@ -118,6 +120,19 @@ void Error::SetXmlPath(const std::string &_xmlPath) | |||
this->dataPtr->xmlPath = _xmlPath; | |||
} | |||
|
|||
///////////////////////////////////////////////// | |||
void Error::throwOrPrintError() |
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.
Yeah, I thought ConsoleStream
inherited from ostream
, but that's not the case, so what you have is good.
#1220 added sdf::Error::ThrowOrPrintError, but after further thought, I think it would be better if we made it a free function inside the internal namespace as this allows us to remove the function without a deprecation cycle. Since the future goal of libsdformat is to remove exceptions, it is likely that we'd want to remove ThrowOrPrintError in the not too distance future. Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Marco A. Gutierrez <[email protected]>
#1220 added sdf::Error::ThrowOrPrintError, but after further thought, I think it would be better if we made it a free function inside the internal namespace as this allows us to remove the function without a deprecation cycle. Since the future goal of libsdformat is to remove exceptions, it is likely that we'd want to remove ThrowOrPrintError in the not too distance future. Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Marco A. Gutierrez [email protected]
🎉 New feature
Related to #1141.
Summary
Because of the request here and as per IM, moving
throwOrPrintErrors
intoError.cc
so now an Error has a method to be thrown or printed and this can be used in current SDFormat header files.Test it
Throw any
Error
object using the new method.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.