fix: propagate errors from DuckDuckGo search and GetResults
Some checks failed
CI / test (pull_request) Failing after 6m12s
CI / vet (pull_request) Failing after 6m12s
CI / build (pull_request) Failing after 6m15s

- Change SearchPage.GetResults() to return ([]Result, error) so ForEach
  errors are no longer silently discarded
- Fix Search() to return the ForEach error instead of nil
- Update cmd caller to check GetResults() errors

Closes #5, #6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 16:16:04 +00:00
parent 49f294e884
commit a12c9f7cb6
3 changed files with 14 additions and 8 deletions

View File

@@ -86,7 +86,10 @@ func main() {
defer extractor.DeferClose(search)
res := search.GetResults()
res, err := search.GetResults()
if err != nil {
return fmt.Errorf("failed to get results: %w", err)
}
fmt.Println("Results:", res)
err = search.LoadMore()
@@ -95,7 +98,10 @@ func main() {
}
time.Sleep(2 * time.Second)
res = search.GetResults()
res, err = search.GetResults()
if err != nil {
return fmt.Errorf("failed to get results: %w", err)
}
fmt.Println("Results:", res)
return nil