Enhance phase sequencing assertions 99/49799/4
authorRobert Varga <rovarga@cisco.com>
Sun, 25 Dec 2016 16:03:55 +0000 (17:03 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 4 Jan 2017 12:45:43 +0000 (12:45 +0000)
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 <rovarga@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java

index 10fc62fe8f2b9c97dda593dd69ffea4d67f67b70..0431b38461195c416cf655ad482776c1d42d717a 100644 (file)
@@ -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<ModifierImpl> 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);
     }