Ignore:
Timestamp:
2014-08-16T11:56:17+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #10380 - throw IllegalDataException instead of RuntimeException with invalid TagChecker rules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r7356 r7417  
    5252import org.openstreetmap.josm.gui.preferences.validator.ValidatorTagCheckerRulesPreference;
    5353import org.openstreetmap.josm.io.CachedFile;
     54import org.openstreetmap.josm.io.IllegalDataException;
    5455import org.openstreetmap.josm.io.UTFInputStreamReader;
    5556import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    195196        }
    196197
    197         static TagCheck ofMapCSSRule(final GroupedMapCSSRule rule) {
     198        static TagCheck ofMapCSSRule(final GroupedMapCSSRule rule) throws IllegalDataException {
    198199            final TagCheck check = new TagCheck(rule);
    199200            boolean containsSetClassExpression = false;
     
    244245                        check.assertions.put(val, false);
    245246                    } else {
    246                         throw new RuntimeException("Cannot add instruction " + ai.key + ": " + ai.val + "!");
     247                        throw new IllegalDataException("Cannot add instruction " + ai.key + ": " + ai.val + "!");
    247248                    }
    248249                }
    249250            }
    250251            if (check.errors.isEmpty() && !containsSetClassExpression) {
    251                 throw new RuntimeException("No "+POSSIBLE_THROWS+" given! You should specify a validation error message for " + rule.selectors);
     252                throw new IllegalDataException("No "+POSSIBLE_THROWS+" given! You should specify a validation error message for " + rule.selectors);
    252253            } else if (check.errors.size() > 1) {
    253                 throw new RuntimeException("More than one "+POSSIBLE_THROWS+" given! You should specify a single validation error message for " + rule.selectors);
     254                throw new IllegalDataException("More than one "+POSSIBLE_THROWS+" given! You should specify a single validation error message for " + rule.selectors);
    254255            }
    255256            return check;
     
    281282            List<TagCheck> result = new ArrayList<>();
    282283            for (Map.Entry<Declaration, List<Selector>> map : g.entrySet()) {
    283                 result.add(TagCheck.ofMapCSSRule(
    284                         new GroupedMapCSSRule(map.getValue(), map.getKey())));
     284                try {
     285                    result.add(TagCheck.ofMapCSSRule(
     286                            new GroupedMapCSSRule(map.getValue(), map.getKey())));
     287                } catch (IllegalDataException e) {
     288                    Main.error("Cannot add MapCss rule: "+e.getMessage());
     289                }
    285290            }
    286291            return result;
Note: See TracChangeset for help on using the changeset viewer.