Changeset 9349 in josm


Ignore:
Timestamp:
2016-01-09T12:10:25+01:00 (9 years ago)
Author:
simon04
Message:

see #12083 - Search: improve error message when keyword without a required parameter is used

Example: foo type bar

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r9067 r9349  
    183183                            return new TimestampRange(minDate, maxDate);
    184184                        } else {
    185                             // I18n: Don't translate timestamp keyword
    186                             throw new ParseError(tr("Expecting <i>min</i>/<i>max</i> after ''timestamp''"));
     185                            throw new ParseError("<html>" + tr("Expecting {0} after {1}", "<i>min</i>/<i>max</i>", "<i>timestamp</i>"));
    187186                        }
    188187                    }
    189                 }
    190             }
    191             return null;
     188                } else {
     189                    throw new ParseError("<html>" + tr("Expecting {0} after {1}", "<code>:</code>", "<i>" + keyword + "</i>"));
     190                }
     191            }
     192            throw new IllegalStateException("Not expecting keyword " + keyword);
    192193        }
    193194
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r9214 r9349  
    22package org.openstreetmap.josm.actions.search;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertFalse;
    56import static org.junit.Assert.assertThat;
     
    379380        anonymous.match(anonymous.n2, true);
    380381    }
     382
     383    @Test
     384    public void testFooTypeBar() throws Exception {
     385        try {
     386            SearchCompiler.compile("foo type bar");
     387            throw new RuntimeException();
     388        } catch (ParseError parseError) {
     389            assertEquals("<html>Expecting <code>:</code> after <i>type<i>", parseError.getMessage());
     390        }
     391    }
    381392}
Note: See TracChangeset for help on using the changeset viewer.