github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/verification/fetcher/errors.go (about)

     1  package fetcher
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/onflow/flow-go/model/flow"
     8  )
     9  
    10  type ChunkDataPackValidationError struct {
    11  	originID        flow.Identifier
    12  	chunkDataPackID flow.Identifier
    13  	chunkID         flow.Identifier
    14  	collectionID    flow.Identifier
    15  	resultID        flow.Identifier
    16  	chunkIndex      uint64
    17  	err             error
    18  }
    19  
    20  func NewChunkDataPackValidationError(originID flow.Identifier,
    21  	resultID flow.Identifier,
    22  	chunkIndex uint64,
    23  	chunkDataPackID flow.Identifier,
    24  	chunkID flow.Identifier,
    25  	collectionID flow.Identifier,
    26  	err error) error {
    27  
    28  	return ChunkDataPackValidationError{
    29  		originID:        originID,
    30  		chunkDataPackID: chunkDataPackID,
    31  		chunkID:         chunkID,
    32  		collectionID:    collectionID,
    33  		resultID:        resultID,
    34  		chunkIndex:      chunkIndex,
    35  		err:             err,
    36  	}
    37  }
    38  
    39  func (c ChunkDataPackValidationError) Error() string {
    40  	return fmt.Sprintf(
    41  		"chunk data pack validation failed, originID: %x, resultID: %x, chunkIndex: %d, chunkDataPackID: %x, chunkID: %x, collectionID: %x, error: %v",
    42  		c.originID,
    43  		c.resultID,
    44  		c.chunkIndex,
    45  		c.chunkDataPackID,
    46  		c.chunkID,
    47  		c.collectionID,
    48  		c.err)
    49  }
    50  
    51  func IsChunkDataPackValidationError(err error) bool {
    52  	return errors.As(err, &ChunkDataPackValidationError{})
    53  }