From 4505d9c355c16c424c6c8b9d744b915120440ed6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 25 Dec 2016 17:03:55 +0100 Subject: [PATCH] Enhance phase sequencing assertions Rather than throwing non-descript exceptions, add explicit messages about what went wrong. Also promote phase sequencing ISE to VerifyException, as it indicate a reactor implementation error. Change-Id: I36d4450a3e81c2f4688065f63d686a24fa11a039 Signed-off-by: Robert Varga --- .../parser/stmt/reactor/SourceSpecificContext.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java index 10fc62fe8f..0431b38461 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java @@ -219,8 +219,15 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh void startPhase(final ModelProcessingPhase phase) { @Nullable final ModelProcessingPhase previousPhase = phase.getPreviousPhase(); - Preconditions.checkState(Objects.equals(previousPhase, finishedPhase)); - Preconditions.checkState(modifiers.get(previousPhase).isEmpty()); + Verify.verify(Objects.equals(previousPhase, finishedPhase), + "Phase sequencing violation: previous phase should be %s, source %s has %s", previousPhase, source, + finishedPhase); + + final Collection previousModifiers = modifiers.get(previousPhase); + Preconditions.checkState(previousModifiers.isEmpty(), + "Previous phase %s has unresolved modifiers %s in source %s", + previousPhase, previousModifiers, source); + inProgressPhase = phase; LOG.debug("Source {} started phase {}", source, phase); } -- 2.36.6