Improve error message for missing phases key#880
Conversation
Codecov Report
@@ Coverage Diff @@
## master #880 +/- ##
=======================================
Coverage 70.49% 70.50%
=======================================
Files 375 375
Lines 45649 45685 +36
=======================================
+ Hits 32182 32210 +28
- Misses 13467 13475 +8
Continue to review full report at Codecov.
|
c59d3bf to
3e03e4a
Compare
974dbdd to
ceb9896
Compare
speth
left a comment
There was a problem hiding this comment.
I think the changes here look good as far as fixing this for the Python module goes. Could you make the corresponding change for the C++ interface (in the newPhase function)?
|
@speth ... oh, for some reason I had assumed that this was Python specific. I guess the same rationale applies in C++ when you call a method on something returned by the |
|
Yes, and I suspect the fix is as simple as what you did here (or simpler, since you won't get into a fight with proper |
868c738 to
561fdae
Compare
|
@speth ... I verified that the same error occurs in C++. So far, so good; after adding a non-const version of However, similar errors can occur for every single instance where the
|
|
Yes, you're right, there are many places where this can occur. I think option (1) would be annoying to police, so I'd rather avoid that. Option (2) is actually not too difficult for } else if (is<void>()) {
throw InputFileError("AnyValue::getMapWhere", *this,
"Key '{}' not found", m_key);We already do a similar check in With this change, I'm wondering whether any of the other changes are even necessary. |
|
@speth ... this is indeed a workable solution! It throws almost the exact same error (minus the list of available keys). I'll update accordingly. |
561fdae to
bd8ffd6
Compare
speth
left a comment
There was a problem hiding this comment.
Looks good. I think the fix for the test files that needed to be added to .gitignore is good - this was the result of changes made in #803, which resulted in the names of some of the regression test executables changing. I didn't notice it at the time because I made those changes on a Windows machine, where all of the test executables are excluded by the *.exe filter in test_problems/.gitignore.
Checklist
scons build&scons test) and unit tests address code coverageIf applicable, fill in the issue number this pull request is fixing
Fixes #812
Changes proposed in this pull request
CxxAnyValue& operator[](string)uses the operator version that adds a key if it is not found (instead of theconstversion that raises an error in C++)AnyMap::atinstead (Cython support for C++constIs incomplete)[]byAnyMap::atin other instancesThe error now points to the actual problem, i.e.