github.com/Finschia/ostracon@v1.1.5/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 // ErrUnsupportedKey is returned when we encounter a private key which doesn't 21 // support generating VRF proof. 22 ErrUnsupportedKey struct { 23 Expected string 24 } 25 26 // VRF verification failure 27 ErrInvalidProof struct { 28 ErrorMessage string 29 } 30 31 // invalid round 32 ErrInvalidRound struct { 33 ConsensusRound int32 34 BlockRound int32 35 } 36 ) 37 38 func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight { 39 return ErrInvalidCommitHeight{ 40 Expected: expected, 41 Actual: actual, 42 } 43 } 44 45 func (e ErrInvalidCommitHeight) Error() string { 46 return fmt.Sprintf("Invalid commit -- wrong height: %v vs %v", e.Expected, e.Actual) 47 } 48 49 func NewErrInvalidCommitSignatures(expected, actual int) ErrInvalidCommitSignatures { 50 return ErrInvalidCommitSignatures{ 51 Expected: expected, 52 Actual: actual, 53 } 54 } 55 56 func (e ErrInvalidCommitSignatures) Error() string { 57 return fmt.Sprintf("Invalid commit -- wrong set size: %v vs %v", e.Expected, e.Actual) 58 } 59 60 func NewErrUnsupportedKey(expected string) ErrUnsupportedKey { 61 return ErrUnsupportedKey{ 62 Expected: expected, 63 } 64 } 65 66 func (e ErrUnsupportedKey) Error() string { 67 return fmt.Sprintf("the private key is not a %s", e.Expected) 68 } 69 70 func NewErrInvalidProof(message string) ErrInvalidProof { 71 return ErrInvalidProof{ErrorMessage: message} 72 } 73 74 func (e ErrInvalidProof) Error() string { 75 return fmt.Sprintf("Proof verification failed: %s", e.ErrorMessage) 76 } 77 78 func NewErrInvalidRound(consensusRound, blockRound int32) ErrInvalidRound { 79 return ErrInvalidRound{ConsensusRound: consensusRound, BlockRound: blockRound} 80 } 81 82 func (e ErrInvalidRound) Error() string { 83 return fmt.Sprintf("Block round(%d) is mismatched to consensus round(%d)", e.BlockRound, e.ConsensusRound) 84 }