Antares_Simulator icon indicating copy to clipboard operation
Antares_Simulator copied to clipboard

Input reading error handling : clarifications

Open guilpier-code opened this issue 1 year ago • 0 comments

At the top of the input reading, we have :

void Application::readDataForTheStudy( /*... */ )
{
    ...
    if (study.loadFromFolder(pSettings.studyFolder, options) && !study.gotFatalError)
    {
        logs.info() << "The study is loaded.";
        logs.info() << LOG_UI_DISPLAY_MESSAGES_OFF;
    }
    ...
    if (study.gotFatalError)
        throw Error::ReadingStudy();
    ...
}

Inside Study::loadFromFolder, we have the recurring pattern scattered over the code :

ret = someLoadingMethod( /*some args*/ ) && ret;

Note that :

  • Study::loadFromFolder returns a boolean. This boolean happens to be false when a file containing an input data could not be loaded correctly for any reason. In this case, the data (should it be a matrix or a simple scalar value) is filled with a default value (matrix : 1 column containing zeros).
  • Boolean Study::gotFatalError is turned to false when a check on an already loaded input data when wrong. As we can see above, this error occurs the triggering of an exception.

At least it's very unclear for any developer. We should find a way to clarify this. For example by replacing ret with loadingDataOK and gotFatalError with checkingDataOK. Maybe some comments somewhere in the code as well, but we have to give some hints. Another solution could be to separate loading and checking in two different functions / entities, each with its own returned code or handling error system (currently, both are mixed).

guilpier-code avatar Oct 17 '23 11:10 guilpier-code