Skip to content

Commit

Permalink
Add error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
gboddin committed Oct 20, 2020
1 parent 6a70717 commit 037bf5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type SearchResultsClient struct {
Page int
ApiKey string
Endpoint string
LastError error
}

const defaultEndpoint = "https://leakix.net"
Expand All @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/leakix/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func Search() {
os.Exit(0)
}
}
if searcher.LastError != nil {
log.Println("finished with errors: " + searcher.LastError.Error())
}
}

func LiveStream() {
Expand Down

0 comments on commit 037bf5d

Please sign in to comment.