Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java	(revision 11560)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java	(revision 11562)
@@ -14,4 +14,5 @@
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.openstreetmap.josm.Main;
@@ -51,10 +52,16 @@
      * @param considerValAsKey whether to consider {@code v} as another key and compare the values of key {@code k} and key {@code v}.
      * @return The new condition.
+     * @throws MapCSSException if the arguments are incorrect
      */
     public static Condition createKeyValueCondition(String k, String v, Op op, Context context, boolean considerValAsKey) {
         switch (context) {
         case PRIMITIVE:
-            if (KeyValueRegexpCondition.SUPPORTED_OPS.contains(op) && !considerValAsKey)
-                return new KeyValueRegexpCondition(k, v, op, false);
+            if (KeyValueRegexpCondition.SUPPORTED_OPS.contains(op) && !considerValAsKey) {
+                try {
+                    return new KeyValueRegexpCondition(k, v, op, false);
+                } catch (PatternSyntaxException e) {
+                    throw new MapCSSException(e);
+                }
+            }
             if (!considerValAsKey && op.equals(Op.EQ))
                 return new SimpleKeyValueCondition(k, v);
@@ -339,4 +346,5 @@
          * @param op operation
          * @param considerValAsKey must be false
+         * @throws PatternSyntaxException if the value syntax is invalid
          */
         public KeyValueRegexpCondition(String k, String v, Op op, boolean considerValAsKey) {
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java	(revision 11560)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java	(revision 11562)
@@ -2,18 +2,43 @@
 package org.openstreetmap.josm.gui.mappaint.mapcss;
 
+/**
+ * MapCSS parsing error, with line/columnn information in error message.
+ */
 public class MapCSSException extends RuntimeException {
 
-    protected final String specialmessage;
+    /** line number at which the parse error occured */
     protected Integer line;
+    /** column number at which the parse error occured */
     protected Integer column;
 
+    /**
+     * Constructs a new {@code MapCSSException} with an explicit error message.
+     * @param specialmessage error message
+     */
     public MapCSSException(String specialmessage) {
-        this.specialmessage = specialmessage;
+        super(specialmessage);
     }
 
+    /**
+     * Constructs a new {@code MapCSSException} with a cause.
+     * @param cause the root cause
+     * @since 11562
+     */
+    public MapCSSException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Sets the column number at which the parse error occured.
+     * @param column the column number at which the parse error occured
+     */
     public void setColumn(int column) {
         this.column = column;
     }
 
+    /**
+     * Sets the line number at which the parse error occured.
+     * @param line the line number at which the parse error occured
+     */
     public void setLine(int line) {
         this.line = line;
@@ -23,6 +48,6 @@
     public String getMessage() {
         if (line == null || column == null)
-            return specialmessage;
-        return String.format("Error at line %s, column %s: %s", line, column, specialmessage);
+            return super.getMessage();
+        return String.format("Error at line %s, column %s: %s", line, column, super.getMessage());
     }
 }
