Index: trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 6210)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java	(revision 6211)
@@ -113,5 +113,10 @@
         }
         StyleCache style = osm.mappaintStyle != null ? osm.mappaintStyle : StyleCache.EMPTY_STYLECACHE;
-        osm.mappaintStyle = style.put(p.a, p.b);
+        try {
+            osm.mappaintStyle = style.put(p.a, p.b);
+        } catch (StyleCache.RangeViolatedError e) {
+            throw new AssertionError("Range violated. object: " + osm.getPrimitiveId() + ", current style: "+osm.mappaintStyle
+                    + ", scale: " + scale + ", new stylelist: " + p.a + ", new range: " + p.b);
+        }
         osm.mappaintCacheIdx = cacheIdx;
         return p;
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 6210)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java	(revision 6211)
@@ -14,5 +14,5 @@
 /**
  * Caches styles for a single primitive.
- * Splits the range of possible scale values (0 < scale < +Infinity) into multiple
+ * Splits the range of possible scale values (0 &lt; scale &lt; +Infinity) into multiple
  * subranges, for each scale range it keeps a list of styles.
  * Immutable class, equals & hashCode is required (the same for StyleList, ElemStyle
@@ -142,4 +142,9 @@
     }
 
+    // this exception type is for debugging #8997 and can later be replaced
+    // by AssertionError
+    public static class RangeViolatedError extends Error {
+    }
+
     /**
      * ASCII-art explanation:
@@ -159,5 +164,5 @@
         if (bd.get(i) == lower) {
             if (upper > bd.get(i+1))
-                throw new AssertionError("the new range must be within a single subrange");
+                throw new RangeViolatedError();
             if (data.get(i) != null)
                 throw new AssertionError("the new range must be within a subrange that has no data");
