Skip to content

Commit

Permalink
disable NotError msg printing
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeperok committed Apr 9, 2019
1 parent e64f88e commit f296408
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions errs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ type ParseError struct {
func (e ParseError) Error() string {
return fmt.Sprintf("%s : %s", e.URL, e.Err.Error())
}

type NotError struct {
Message string
}

func (e NotError) Error() string {
return e.Message
}
2 changes: 1 addition & 1 deletion scrape/encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (r *storageResultReader) getValue() (map[string]interface{}, error) {
})

if err != nil {
logger.Sugar().Errorf(fmt.Sprintf(errs.NoKey, key))
//logger.Sugar().Errorf(fmt.Sprintf(errs.NoKey, key))
return nil, err //&errs.ErrStorageResult{Err: fmt.Sprintf(errs.NoKey, key)}
}
blockMap := make(map[string]interface{})
Expand Down
10 changes: 7 additions & 3 deletions scrape/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (f *Field) extract(content *goquery.Selection, results *map[string]interfac
})
switch len(values) {
case 0:
return fmt.Errorf("%s", errs.ErrEmptyResults)
return errs.NotError{Message: "No selectors found in current block. Thats OK."}
case 1:
(*results)[f.Name+"_"+attr] = values[0]
default:
Expand Down Expand Up @@ -422,7 +422,9 @@ func (task *Task) paginate(ctx context.Context, in <-chan flow, nextPageSelector
paginator := make(map[string]interface{})
err = f.extract(doc.Selection, &paginator, task.templateRequest.URL) /* tw.scraper.Paginator.NextPage(url, doc.Selection) */
if err != nil {
errc <- errs.ParseError{data.url, err}
if _, ok := err.(errs.NotError); !ok {
errc <- errs.ParseError{data.url, err}
}
close(fetcherChannel)
return
}
Expand Down Expand Up @@ -558,7 +560,9 @@ func (task *Task) parse(ctx context.Context, in <-chan flow, fields []Field, isP
}
err := field.extract(block, &blockResult, task.templateRequest.URL)
if err != nil {
errc <- err
if _, ok := err.(errs.NotError); !ok {
errc <- err
}
continue
}
if len(field.Details.Fields) > 0 {
Expand Down

0 comments on commit f296408

Please sign in to comment.