diff --git a/lib/api.dart b/lib/api.dart index bf0f58a..0eb26df 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -42,17 +42,12 @@ Future searchForExamples(String phrase) async { /// instead of かかる (no results). Future scrapeForPhrase(String phrase) async { final uri = uriForPhraseScrape(phrase); - try { - final response = await http.get(uri); - return parsePhrasePageData(response.body, phrase); - } catch (err) { - // if (response.statusCode == 404) { - // return PhrasePageScrapeResult( - // query: phrase, - // found: false, - // ); - // } - - rethrow; + final response = await http.get(uri); + if (response.statusCode == 404) { + return PhrasePageScrapeResult( + query: phrase, + found: false, + ); } + return parsePhrasePageData(response.body, phrase); } \ No newline at end of file diff --git a/lib/src/exampleSearch.dart b/lib/src/exampleSearch.dart index 0725c36..d194b8d 100644 --- a/lib/src/exampleSearch.dart +++ b/lib/src/exampleSearch.dart @@ -113,7 +113,7 @@ ExampleResults parseExamplePageData(String pageHtml, String phrase) { final document = parse(pageHtml); final divs = document.querySelectorAll('.sentence_content'); - final results = divs.map((div) => _parseExampleDiv(div)).toList(); + final results = divs.map(_parseExampleDiv).toList(); return ExampleResults( query: phrase,