Skip to content

Commit eebbf56

Browse files
committed
incremental: improve error messages
1 parent 125bd72 commit eebbf56

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

incremental/src/main/java/net/automatalib/incremental/ConflictException.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020
*/
2121
public class ConflictException extends IllegalArgumentException {
2222

23-
/**
24-
* Creates an exception with no specific error message.
25-
*
26-
* @see IllegalArgumentException#IllegalArgumentException()
27-
*/
28-
public ConflictException() {
29-
// default constructor
30-
}
31-
3223
/**
3324
* Creates an exception with a given error message.
3425
*

incremental/src/main/java/net/automatalib/incremental/mealy/tree/DynamicIncrementalMealyTreeBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public void insert(Word<? extends I> input, Word<? extends O> outputWord) {
6565
curr = insertNode(curr, sym, out);
6666
} else {
6767
if (!Objects.equals(out, edge.getOutput())) {
68-
throw new ConflictException();
68+
throw new ConflictException(
69+
"Error inserting " + input.prefix(i + 1) + " / " + outputWord.prefix(i + 1) +
70+
": Incompatible output symbols: " + out + " vs " + edge.getOutput());
6971
}
7072
curr = edge.getTarget();
7173
}

incremental/src/main/java/net/automatalib/incremental/mealy/tree/IncrementalMealyTreeBuilder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public void insert(Word<? extends I> input, Word<? extends O> outputWord) {
4949
curr = insertNode(curr, sym, out);
5050
} else {
5151
if (!Objects.equals(out, edge.getOutput())) {
52-
throw new ConflictException();
52+
throw new ConflictException(
53+
"Error inserting " + input.prefix(i + 1) + " / " + outputWord.prefix(i + 1) +
54+
": Incompatible output symbols: " + out + " vs " + edge.getOutput());
5355
}
5456
curr = edge.getTarget();
5557
}

incremental/src/main/java/net/automatalib/incremental/moore/tree/IncrementalMooreTreeBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,12 @@ public void insert(Word<? extends I> word, Word<? extends O> output) {
190190
for (I sym : word) {
191191
int inputIdx = alphabet.getSymbolIndex(sym);
192192
Node<O> succ = curr.getChild(inputIdx);
193+
O out = outIter.next();
193194
if (succ == null) {
194-
succ = new Node<>(outIter.next());
195+
succ = new Node<>(out);
195196
curr.setChild(inputIdx, alphabetSize, succ);
196-
} else if (!Objects.equals(succ.getOutput(), outIter.next())) {
197-
throw new ConflictException();
197+
} else if (!Objects.equals(succ.getOutput(), out)) {
198+
throw new ConflictException("Incompatible outputs: " + succ.getOutput() + " vs " + out);
198199
}
199200
curr = succ;
200201
}

0 commit comments

Comments
 (0)