Skip to content

Commit

Permalink
more meaningful error message when there are no contingencies to simu…
Browse files Browse the repository at this point in the history
…late
  • Loading branch information
Christian Biasuzzi committed Nov 25, 2016
1 parent 87ce7c5 commit be6aa25
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -7,10 +7,10 @@
package eu.itesla_project.eurostag;

import com.google.common.base.Strings;
import eu.itesla_project.iidm.eurostag.export.EurostagDictionary;
import eu.itesla_project.iidm.network.*;
import eu.itesla_project.contingency.Contingency;
import eu.itesla_project.contingency.ContingencyElement;
import eu.itesla_project.iidm.eurostag.export.EurostagDictionary;
import eu.itesla_project.iidm.network.*;
import eu.itesla_project.simulation.SimulationParameters;
import org.jboss.shrinkwrap.api.Domain;
import org.jboss.shrinkwrap.api.GenericArchive;
Expand Down Expand Up @@ -136,8 +136,7 @@ public void writeFaultSeq(BufferedWriter writer, Contingency contingency, Networ
writer.newLine();
for (ContingencyElement element : contingency.getElements()) {
switch (element.getType()) {
case LINE:
{
case LINE: {
Line l = network.getLine(element.getId());
if (l == null) {
throw new RuntimeException("Line '" + element.getId() + "' not found");
Expand Down Expand Up @@ -194,8 +193,7 @@ public void writeFaultSeq(BufferedWriter writer, Contingency contingency, Networ
}
break;

case GENERATOR:
{
case GENERATOR: {
Generator g = network.getGenerator(element.getId());
if (g == null) {
throw new RuntimeException("Generator '" + element.getId() + "' not found");
Expand Down Expand Up @@ -252,6 +250,9 @@ public GenericArchive writeFaultSeqArchive(List<Contingency> contingencies, Netw
}

public GenericArchive writeFaultSeqArchive(Domain domain, List<Contingency> contingencies, Network network, EurostagDictionary dictionary, Function<Integer, String> seqFileNameFct) throws IOException {
if ((contingencies == null) || (contingencies.isEmpty())) {
throw new RuntimeException("contingencies list is empty, cannot write .seq scenario files");
}
GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
Path rootDir = fileSystem.getPath("/");
Expand Down

0 comments on commit be6aa25

Please sign in to comment.