FGInitialCondition::Load throws instead of returning false#1408
FGInitialCondition::Load throws instead of returning false#1408AirshipSim wants to merge 2 commits intoJSBSim-Team:masterfrom
Conversation
… engine property reading to Load_running function.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1408 +/- ##
==========================================
- Coverage 25.22% 25.21% -0.02%
==========================================
Files 169 169
Lines 18633 18641 +8
==========================================
Hits 4701 4701
- Misses 13932 13940 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
That's a hard no-go as far as I am concerned: #1407 (comment) |
@bcoconni You are the person telling me to open a PR at the end of the discussion... Logic has left the chat. |
First, I have indeed told you to open the PR but never implied that we would accept your change upfront. Second, as I explained earlier (see #1407 (comment)):
try {
if (!Exec->LoadScript(SGPath{ ResetPath}, dt, SGPath{ InitPath }))
{
return false;
}
}
catch (const JSBSim::LogException&) {
return false;
}
So I find that I am pretty consistent with myself. Third, my previous comment may have sounded firm, but it focused solely on the technical aspects. There was no personal remark or judgment. I expect discussions to challenge facts and design choices, not individuals. So I stand by my position. And anyone is free to challenge my opinions even when they are strong. As far as I am concerned, the discussion remains open to technical arguments. |
|
@AirshipSim @bcoconni did make his views on swallowing exceptions quite clear in the discussion. You're free to still add a try/catch to your PR, but you can't be surprised that @bcoconni will re-iterate the point he made in the discussion. |
Following discussion #1407
Hint: Hide white space differences when checking Files changes
The function
FGInitialCondition::Loadwas obviously patched up along the years. Upon error, it couldIt is now unified to return false in all cases. Functions inside Load( ) which could throw are now guarded by a try / catch.
Other corrected minor issue: the reading of engine configuration was done directly in FGInitialCondition::Load( ), instead of being done in the functions Load_v1 or Load_v2 like any other tag.
Current usage in the codebase
In the codebase, Load( ) was called in two different places:
jsbsim/src/input_output/FGScript.cpp
Lines 195 to 200 in 98c0333
jsbsim/src/JSBSim.cpp
Lines 477 to 482 in 98c0333
In both cases, the return value ( true or false ) was correctly checked, nothing to do there.
Testing
Testing in command line, the errors are caught correctly and JSBSim terminates with the proper error message, instead of terminate suddenly with FATAL ERROR and less log: