Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 5840)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 5841)
@@ -3,8 +3,8 @@
 
 import java.util.List;
+import java.util.regex.PatternSyntaxException;
 
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
@@ -196,10 +196,44 @@
         }
     }
-
-    public static class LinkSelector implements Selector {
-        protected List<Condition> conditions;
+    
+    /**
+     * Super class of {@link GeneralSelector} and {@link LinkSelector}
+     * @since 5841
+     */
+    public static abstract class AbstractSelector implements Selector {
+
+        protected final List<Condition> conds;
+        
+        protected AbstractSelector(List<Condition> conditions) {
+            if (conditions == null || conditions.isEmpty()) {
+                this.conds = null;
+            } else {
+                this.conds = conditions;
+            }
+        }
+
+        /**
+         * Determines if all conditions match the given environment.
+         * @param env The environment to check
+         * @return {@code true} if all conditions apply, false otherwise.
+         */
+        public final boolean matchesConditions(Environment env) {
+            if (conds == null) return true;
+            for (Condition c : conds) {
+                try {
+                    if (!c.applies(env)) return false;
+                } catch (PatternSyntaxException e) {
+                    System.err.println("PatternSyntaxException while applying condition" + c +": "+e.getMessage());
+                    return false;
+                }
+            }
+            return true;
+        }
+    }
+
+    public static class LinkSelector extends AbstractSelector {
 
         public LinkSelector(List<Condition> conditions) {
-            this.conditions = conditions;
+            super(conditions);
         }
 
@@ -207,8 +241,5 @@
         public boolean matches(Environment env) {
             Utils.ensure(env.isLinkContext(), "Requires LINK context in environment, got ''{0}''", env.getContext());
-            for (Condition c: conditions) {
-                if (!c.applies(env)) return false;
-            }
-            return true;
+            return matchesConditions(env);
         }
 
@@ -225,15 +256,15 @@
         @Override
         public String toString() {
-            return "LinkSelector{" + "conditions=" + conditions + '}';
+            return "LinkSelector{" + "conditions=" + conds + '}';
         }
     }
 
-    public static class GeneralSelector implements Selector {
+    public static class GeneralSelector extends AbstractSelector {
         private String base;
         public Range range;
-        private List<Condition> conds;
         private String subpart;
 
         public GeneralSelector(String base, Pair<Integer, Integer> zoom, List<Condition> conds, String subpart) {
+            super(conds);
             this.base = base;
             if (zoom != null) {
@@ -246,9 +277,4 @@
             if (range == null) {
                 range = new Range();
-            }
-            if (conds == null || conds.isEmpty()) {
-                this.conds = null;
-            } else {
-                this.conds = conds;
             }
             this.subpart = subpart;
@@ -281,13 +307,4 @@
         }
 
-        public boolean matchesConditions(Environment e){
-            if (conds == null) return true;
-            for (Condition c : conds) {
-                if (!c.applies(e))
-                    return false;
-            }
-            return true;
-        }
-
         @Override
         public boolean matches(Environment e) {
