Tidying error handling and adding some fluff.
This commit is contained in:
@@ -2,6 +2,7 @@ package nrod
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -22,7 +23,6 @@ func NrodStream(url string, cfg *helpers.Configuration) (io.ReadCloser, error) {
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Error("Error creating HTTP Request", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -34,9 +34,13 @@ func NrodStream(url string, cfg *helpers.Configuration) (io.ReadCloser, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp == nil {
|
||||
err = errors.New("http response error - response = nil")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
err := fmt.Errorf("unexpected status code: %d", resp.StatusCode)
|
||||
log.Error("Non-successful status code", zap.Error(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user