Skip to content

Commit

Permalink
adds a detailed message to the generic throwsUnexpectedTopology's
Browse files Browse the repository at this point in the history
  • Loading branch information
CBiasuzzi committed Nov 30, 2017
1 parent c62a020 commit 971dc26
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,11 @@ public static InsertionStatus insert(Generator g, EurostagDDB ddb, IdDictionary
return insert(g, ddbFile, auxDict, config, stateBefore);
}

private static void throwsUnexpectedTopology() {
throw new RuntimeException("Unexpected stator substation topology");
private static void throwsUnexpectedTopology(Bus lvBus, String detailsMessage) {
Objects.requireNonNull(lvBus);
String errorMessage = "Unexpected stator substation topology in connected/connectable equipments for voltage level '" + lvBus.getVoltageLevel() + "', bus '" + lvBus + "' when removing existing step-up transformers (expected one TwoWindingTransformer, one or more Generators, zero or more Loads). " + detailsMessage;
LOGGER.error(errorMessage);
throw new RuntimeException(errorMessage);
}

private static void removeStepUpTransformersAlreadyPresents(Network n, List<String> statorVoltageLevels,
Expand All @@ -522,6 +525,7 @@ private static void removeStepUpTransformersAlreadyPresents(Network n, List<Stri
for (String lvVlId : statorVoltageLevels) {
VoltageLevel lvVl = n.getVoltageLevel(lvVlId);
if (lvVl == null) {
LOGGER.warn("skipping stator voltage level '" + lvVlId + "' when removing existing step-up transformers: id not found in network");
continue;
}

Expand Down Expand Up @@ -556,27 +560,27 @@ public void visitGenerator(Generator generator) {

@Override
public void visitBusbarSection(BusbarSection section) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found a BusbarSection: " + section);
}

@Override
public void visitDanglingLine(DanglingLine danglingLine) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found a DanglinLine: " + danglingLine);
}

@Override
public void visitLine(Line line, Line.Side side) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found a Line: " + line);
}

@Override
public void visitShuntCompensator(ShuntCompensator sc) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found a ShuntCompensator: " + sc);
}

@Override
public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found a ThreewindingTransformer: " + transformer);
}
});

Expand All @@ -591,7 +595,7 @@ public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer,
}

if (twtLs.size() != 1) {
throwsUnexpectedTopology();
throwsUnexpectedTopology(lvBus, "Found more than one TwoWindingTransformer: " + twtLs.stream().map(TwoWindingsTransformer::getId).collect(Collectors.joining(",")));
}

TwoWindingsTransformer twt = twtLs.get(0);
Expand Down

0 comments on commit 971dc26

Please sign in to comment.