From 037bf5d2254f4c2eebeea7b0652cfd81b3b3c800 Mon Sep 17 00:00:00 2001 From: Gregory Boddin Date: Tue, 20 Oct 2020 22:32:11 +0200 Subject: [PATCH] Add error reporting --- Client.go | 4 +++- cmd/leakix/main.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Client.go b/Client.go index d41e410..fadd33b 100644 --- a/Client.go +++ b/Client.go @@ -33,6 +33,7 @@ type SearchResultsClient struct { Page int ApiKey string Endpoint string + LastError error } const defaultEndpoint = "https://leakix.net" @@ -45,12 +46,13 @@ func (sc *SearchResultsClient) GetEndpoint() string { } func (sc *SearchResultsClient) Next() bool { + var results []SearchResult if len(sc.SearchResults) > sc.Position { sc.Position++ return true } // Try to load next page - results, _ := sc.GetSearchResults(sc.Scope, sc.Query, sc.Page) + results, sc.LastError = sc.GetSearchResults(sc.Scope, sc.Query, sc.Page) for _, result := range results { sc.SearchResults = append(sc.SearchResults, result) } diff --git a/cmd/leakix/main.go b/cmd/leakix/main.go index 14bedfe..9c80f35 100644 --- a/cmd/leakix/main.go +++ b/cmd/leakix/main.go @@ -71,6 +71,9 @@ func Search() { os.Exit(0) } } + if searcher.LastError != nil { + log.Println("finished with errors: " + searcher.LastError.Error()) + } } func LiveStream() {