github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/config/errors.go (about)

     1  package p2pconfig
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	p2pmsg "github.com/onflow/flow-go/network/p2p/message"
     8  )
     9  
    10  // InvalidLimitConfigError indicates the validation limit is < 0.
    11  type InvalidLimitConfigError struct {
    12  	err error
    13  }
    14  
    15  func (e InvalidLimitConfigError) Error() string {
    16  	return e.err.Error()
    17  }
    18  
    19  func (e InvalidLimitConfigError) Unwrap() error {
    20  	return e.err
    21  }
    22  
    23  // NewInvalidLimitConfigErr returns a new ErrValidationLimit.
    24  func NewInvalidLimitConfigErr(controlMsg p2pmsg.ControlMessageType, err error) InvalidLimitConfigError {
    25  	return InvalidLimitConfigError{fmt.Errorf("invalid rpc control message %s validation limit configuration: %w", controlMsg, err)}
    26  }
    27  
    28  // IsInvalidLimitConfigError returns whether an error is ErrInvalidLimitConfig.
    29  func IsInvalidLimitConfigError(err error) bool {
    30  	var e InvalidLimitConfigError
    31  	return errors.As(err, &e)
    32  }