github.com/project-88388/tendermint-v0.34.14-terra.2@v1.0.0/types/errors.go (about)

     1  package types
     2  
     3  import "fmt"
     4  
     5  type (
     6  	// ErrInvalidCommitHeight is returned when we encounter a commit with an
     7  	// unexpected height.
     8  	ErrInvalidCommitHeight struct {
     9  		Expected int64
    10  		Actual   int64
    11  	}
    12  
    13  	// ErrInvalidCommitSignatures is returned when we encounter a commit where
    14  	// the number of signatures doesn't match the number of validators.
    15  	ErrInvalidCommitSignatures struct {
    16  		Expected int
    17  		Actual   int
    18  	}
    19  )
    20  
    21  func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight {
    22  	return ErrInvalidCommitHeight{
    23  		Expected: expected,
    24  		Actual:   actual,
    25  	}
    26  }
    27  
    28  func (e ErrInvalidCommitHeight) Error() string {
    29  	return fmt.Sprintf("Invalid commit -- wrong height: %v vs %v", e.Expected, e.Actual)
    30  }
    31  
    32  func NewErrInvalidCommitSignatures(expected, actual int) ErrInvalidCommitSignatures {
    33  	return ErrInvalidCommitSignatures{
    34  		Expected: expected,
    35  		Actual:   actual,
    36  	}
    37  }
    38  
    39  func (e ErrInvalidCommitSignatures) Error() string {
    40  	return fmt.Sprintf("Invalid commit -- wrong set size: %v vs %v", e.Expected, e.Actual)
    41  }