github.com/koko1123/flow-go-1@v0.29.6/module/mempool/errors.go (about)

     1  package mempool
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  // UnknownExecutionResultError indicates that the Execution Result is unknown
     9  type UnknownExecutionResultError struct {
    10  	err error
    11  }
    12  
    13  func NewUnknownExecutionResultError(msg string) error {
    14  	return NewUnknownExecutionResultErrorf(msg)
    15  }
    16  
    17  func NewUnknownExecutionResultErrorf(msg string, args ...interface{}) error {
    18  	return UnknownExecutionResultError{
    19  		err: fmt.Errorf(msg, args...),
    20  	}
    21  }
    22  
    23  func (e UnknownExecutionResultError) Unwrap() error {
    24  	return e.err
    25  }
    26  
    27  func (e UnknownExecutionResultError) Error() string {
    28  	return e.err.Error()
    29  }
    30  
    31  // IsUnknownExecutionResultError returns whether the given error is an UnknownExecutionResultError error
    32  func IsUnknownExecutionResultError(err error) bool {
    33  	var unknownExecutionResultError UnknownExecutionResultError
    34  	return errors.As(err, &unknownExecutionResultError)
    35  }
    36  
    37  // DecreasingPruningHeightError indicates that we are pruning a mempool by a height that
    38  // is lower than existing height
    39  type DecreasingPruningHeightError struct {
    40  	err error
    41  }
    42  
    43  func NewDecreasingPruningHeightError(msg string) error {
    44  	return NewDecreasingPruningHeightErrorf(msg)
    45  }
    46  
    47  func NewDecreasingPruningHeightErrorf(msg string, args ...interface{}) error {
    48  	return DecreasingPruningHeightError{
    49  		err: fmt.Errorf(msg, args...),
    50  	}
    51  }
    52  
    53  func (e DecreasingPruningHeightError) Unwrap() error {
    54  	return e.err
    55  }
    56  
    57  func (e DecreasingPruningHeightError) Error() string {
    58  	return e.err.Error()
    59  }
    60  
    61  // IsDecreasingPruningHeightError returns whether the given error is an DecreasingPruningHeightError error
    62  func IsDecreasingPruningHeightError(err error) bool {
    63  	var newIsDecreasingPruningHeightError DecreasingPruningHeightError
    64  	return errors.As(err, &newIsDecreasingPruningHeightError)
    65  }