diff --git a/core/src/main/java/com/graphhopper/util/ViaInstruction.java b/core/src/main/java/com/graphhopper/util/ViaInstruction.java
index <HASH>..<HASH> 100644
--- a/core/src/main/java/com/graphhopper/util/ViaInstruction.java
+++ b/core/src/main/java/com/graphhopper/util/ViaInstruction.java
@@ -42,6 +42,9 @@ public class ViaInstruction extends Instruction
 
     public int getViaCount()
     {
+        if (viaPosition < 0)
+            throw new IllegalStateException("Uninitialized via count in instruction " + getName());
+
         return viaPosition;
     }
throw exception if via count is uninitialized