chore: add requestID to error message in store validation

This commit is contained in:
Richard Ramos 2024-09-17 10:13:01 -04:00
parent bc2444ca46
commit 991e872de9
No known key found for this signature in database
GPG Key ID: 1CE87DB518195760

View File

@ -1,7 +1,9 @@
package pb
import (
"encoding/hex"
"errors"
"fmt"
)
// MaxContentTopics is the maximum number of allowed contenttopics in a query
@ -10,7 +12,6 @@ const MaxContentTopics = 10
var (
errMissingRequestID = errors.New("missing RequestId field")
errMessageHashOtherFields = errors.New("cannot use MessageHashes with ContentTopics/PubsubTopic")
errRequestIDMismatch = errors.New("requestID in response does not match request")
errMaxContentTopics = errors.New("exceeds the maximum number of ContentTopics allowed")
errEmptyContentTopic = errors.New("one or more content topics specified is empty")
errMissingPubsubTopic = errors.New("missing PubsubTopic field")
@ -58,7 +59,7 @@ func (x *StoreQueryRequest) Validate() error {
func (x *StoreQueryResponse) Validate(requestID string) error {
if x.RequestId != "" && x.RequestId != requestID {
return errRequestIDMismatch
return fmt.Errorf("requestID %s in response does not match requestID in request %s", hex.EncodeToString([]byte(x.RequestId)), hex.EncodeToString([]byte(requestID)))
}
if x.StatusCode == nil {