-
Notifications
You must be signed in to change notification settings - Fork 89
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
ObjectPath XML errors feedback #2341
Conversation
(solving Issue 2320.2.1)
- getPath() call on the Problem node now returns "Problem"
(issue 2320 case 2.2)
- added exception throwing from the MeshObjectPath constructor
…l-errors-feedback
(this was the behaviour before this PR)
src/coreComponents/fileIO/timeHistory/HistoryCollectionBase.cpp
Outdated
Show resolved
Hide resolved
src/coreComponents/unitTests/dataRepositoryTests/testGroupPath.cpp
Outdated
Show resolved
Hide resolved
- Added a constructor to InputError to add text in a previously caught exception.
src/coreComponents/fileIO/timeHistory/HistoryCollectionBase.cpp
Outdated
Show resolved
Hide resolved
- GEOSX_FMT param id fix
Sorry to chime in uninvited and this late into the PR's lifecycle, but I find the whole approach of parsing error messages and attempting to insert text in the middle logically "backwards" and extremely brittle. If someone changes the message format in LvArray logging macro and replaces 5 stars with 4 or something, this functionality might be silently broken. Not to stand in the way of merging this as is (it is an improvement for end users), but we should consider an overall change to how throwing macros work: instead of adding all the extra formatting (rank number, stars, etc.) at the source of throw, we should throw just the succinct error message and add all the other stuff at the end (when the message gets printed). This will allow us to easily "stack" multiple contexts (messages) line-by-line as the exception propagates up the call stack, without having to parse the previous text. We could even preserve the original exception object and wrap it in the new one that gets re-thrown (e.g. nested_exception). This would be a separate PR, if anyone has free cycles to do it. |
You're absolutely correct. I think we would better keep the initial information of the exception in a more meaningful way (not in a raw
Most likely not, since this would result in broken unit tests.
This surely makes sense, but...
... this is the eternal issue. |
- used stringutilities::cstrlen where it could be - made InsertExMsg a free function
@@ -334,7 +349,12 @@ class Group | |||
T const & getGroup( KEY const & key ) const | |||
{ | |||
Group const * const child = m_subGroups[ key ]; | |||
GEOSX_THROW_IF( child == nullptr, "Group " << getPath() << " doesn't have a child " << key, std::domain_error ); | |||
if( child == nullptr ) |
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.
So why did you convert GEOSX_THROW_IF
into GEOSX_THROW
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.
I forgot to change them back, I previously used std::vector
to store the names.
This PR aims:
1. To prevents crashing when PathCollection::objectPath is wrong (thus, solving the case 2.1 of the issue #2320)
2. Add a context in case of a wrong PackCollection or FieldSpecification objectPath so we know from which object the error comes from (thus, solving the case 2.2 of the issue #2320).
In order to output the name of the Group with a wrong objectPath, this PR propose to use the GEOSX_THROW macros and try-catch to add a context to the originally thrown exception (inserting a line starting with
***** ERROR:
):3. To fix Group::getPath() so it no longer starts with
m/
but with/
(thatm
was the end ofProblem
which seemed wrongly cut). This fix will help a bit to output clearer path errors (this was the only use of getPath()). The returned path would be of the following form:/Tasks/myPackCollection
(the leading/
symbolizing it is an absolute path)I added
testGroupPath
to test: