diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java index 71a9bce2f18..355ca2b1718 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java @@ -904,7 +904,7 @@ public void addGeneralStats(SurveyJSONWrapper r) { r.put("time_now", System.currentTimeMillis()); } - private JSONArray searchResults(String q, CLDRLocale l) { + private JSONArray searchResults(String q, CLDRLocale l) throws JSONException { JSONArray results = new JSONArray(); if (q != null) { @@ -938,21 +938,20 @@ private void searchLocales(JSONArray results, String q) { } } - private void searchPathheader(JSONArray results, CLDRLocale l, String q) { + private void searchPathheader(JSONArray results, CLDRLocale l, String q) throws JSONException { if (l == null) { return; // don't search with no locale } - try { - PathHeader.PageId page = PathHeader.PageId.valueOf(q); + PathHeader.PageId page = PathHeader.PageId.forString(q); + if (page != null) { results.put( new JSONObject() .put("page", page.name()) .put("section", page.getSectionId().name())); - } catch (Throwable t) { - // } + try { - PathHeader.SectionId section = PathHeader.SectionId.valueOf(q); + PathHeader.SectionId section = PathHeader.SectionId.forString(q); results.put(new JSONObject().put("section", section.name())); } catch (Throwable t) { // diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java index efa531d45e3..5051dd5b42d 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/VoteAPIHelper.java @@ -185,9 +185,8 @@ public static RowResponse getRowsResponse( String xp = null; if (args.xpstrid == null && args.page != null) { - try { - pageId = PageId.valueOf(args.page); - } catch (IllegalArgumentException iae) { + pageId = PageId.forString(args.page); + if (pageId == null) { throw new SurveyException(ErrorCode.E_BAD_SECTION); } if (pageId.getSectionId() == org.unicode.cldr.util.PathHeader.SectionId.Special) {