srlabUsask / crhmcode

GNU General Public License v3.0
7 stars 4 forks source link

throw TExcept during module initialization won't immediately terminate the run #309

Closed lawfordp2017 closed 2 years ago

lawfordp2017 commented 2 years ago

In case of an error in the project configuration file, some modules have checks during initialization such as the following:

                    CRHMException TExcept(S.c_str(), TExcept::TERMINATE);
                    LogError(TExcept);
                    throw TExcept;

I think the intention is that crhm should stop immediately and report the error but what actually happens is crhm stops initializing the remaining modules, leaving them in a half-initialized state and then attempts to do the run.

I mean TExcept::TERMINATE specifically, some other TExcepts may not need to terminate.

jhs507 commented 2 years ago

I agree any instance of a TExcept::TERMINATE level exception should end execution. I will take a look at this.

Could you provide a project file that you were using when you encountered this?

jhs507 commented 2 years ago

Did you encounter this while using the GUI or the CLI?

lawfordp2017 commented 2 years ago

Using the CLI. I encountered using the waterquality modules, which require some other code modification to work, but I'll try to find an example without waterquality.

jhs507 commented 2 years ago

I believe that I have found a solution that shouldn't take too long to implement.

Unfortunately, I don't think the code base handles exceptions well in general and we should do a refactor to correct this at some point.

In this case I believe it is just an oversight in my main driver method for the CLI so I should be able to fix it without a whole refactor.

lawfordp2017 commented 2 years ago

Closing as I believe the change fixes the issue.