Skip to content
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

Fix the handle of not applicable NetworkModification when throwException boolean is present #3204

Open
alicecaron opened this issue Nov 7, 2024 · 0 comments

Comments

@alicecaron
Copy link

In the NetworkModification::apply methods that take the throwException boolean in input parameter the use of AbstractNetworkModification::logOrThrow method should be called when the network modification cannot be applied.

This method allows to either log the not applicable reason as a warning (if throwException=false) or to throw a PowsyblException (if throwException=true).

Problem:
Some of the NetworkModification::apply method implementations do not call this method when the modification can not be applied.

Solution:
Fix each of thoses implementations to use the logOrThrow method.

Example:
In ConnectGenerator::apply we throw a PowsyblException in some case, but we should logOrThrow instead (and in case it is a log we should then return):

Replace

throw new PowsyblException("Generator '" + generatorId + "' not found");

With

logOrThrow(throwException, "Generator '" + generatorId + "' not found");
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: TODO
Development

No branches or pull requests

1 participant