diff --git a/pkg/archiverappliance/aaclient.go b/pkg/archiverappliance/aaclient.go index 5a4843e..8d00ffd 100644 --- a/pkg/archiverappliance/aaclient.go +++ b/pkg/archiverappliance/aaclient.go @@ -23,13 +23,6 @@ type AAclient struct { baseURL string } -type EmptyResponseError struct { -} - -func (e *EmptyResponseError) Error() string { - return "response is empty" -} - func NewAAClient(ctx context.Context, url string) (*AAclient, error) { return &AAclient{ baseURL: url, @@ -163,7 +156,7 @@ func archiverSingleQueryParser(jsonAsBytes []byte) (models.SingleData, error) { if len(response) < 1 { log.DefaultLogger.Warn("Response is empty") - return sD, &EmptyResponseError{} + return sD, errEmptyResponse } var d models.DataResponse diff --git a/pkg/archiverappliance/error.go b/pkg/archiverappliance/error.go new file mode 100644 index 0000000..8e086f0 --- /dev/null +++ b/pkg/archiverappliance/error.go @@ -0,0 +1,7 @@ +package archiverappliance + +import "errors" + +var ( + errEmptyResponse = errors.New("response is empty") +) diff --git a/pkg/archiverappliance/query.go b/pkg/archiverappliance/query.go index 3f0826c..b1cd026 100644 --- a/pkg/archiverappliance/query.go +++ b/pkg/archiverappliance/query.go @@ -94,8 +94,7 @@ responseCollector: select { case response := <-responsePipe: if response.err != nil { - emptyError := &EmptyResponseError{} - if qm.IgnoreEmptyErr && errors.Is(response.err, emptyError) { + if qm.IgnoreEmptyErr && errors.Is(response.err, errEmptyResponse) { continue } diff --git a/pkg/archiverappliance/query_test.go b/pkg/archiverappliance/query_test.go index 19f7604..be3ac2f 100644 --- a/pkg/archiverappliance/query_test.go +++ b/pkg/archiverappliance/query_test.go @@ -32,7 +32,7 @@ func (f fakeClient) ExecuteSingleQuery(target string, qm models.ArchiverQueryMod return models.SingleData{}, errors.New("test error") } if target == "emptyErr" { - return models.SingleData{}, &EmptyResponseError{} + return models.SingleData{}, errEmptyResponse } var v models.Values @@ -534,8 +534,7 @@ func TestQueryWithEmptyResponse(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { result := Query(testCase.ctx, f, testCase.req, testCase.config) res := result.Responses["A"] - emptyError := &EmptyResponseError{} - if !errors.Is(res.Error, emptyError) { + if !errors.Is(res.Error, errEmptyResponse) { t.Errorf("An unexpected error has occurred") } if len(res.Frames) != 1 {