Skip to content

Commit

Permalink
Return err instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsignalfx committed May 5, 2021
1 parent 5c4ca8a commit b156d7a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/splunk/httprequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package splunk

import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"strconv"
Expand Down Expand Up @@ -55,12 +54,12 @@ func HandleHTTPCode(resp *http.Response) error {
err = exporterhelper.NewThrottleRetry(err, time.Duration(retryAfter)*time.Second)
// Check for permanent errors.
case http.StatusBadRequest, http.StatusUnauthorized:
var dump []byte
dump, err = httputil.DumpResponse(resp, true)
if err != nil {
log.Fatal(err)
dump, err2 := httputil.DumpResponse(resp, true)
if err2 == nil {
err = consumererror.Permanent(fmt.Errorf("%w", fmt.Errorf("%q", dump)))
} else {
err = consumererror.Combine([]error{err, err2})
}
err = consumererror.Permanent(fmt.Errorf("%w", fmt.Errorf("%q", dump)))
}

return err
Expand Down

0 comments on commit b156d7a

Please sign in to comment.