forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: export p2p package errors (cometbft#1901)
This PR Contributes to: cometbft#1140 Changes: - Exports errors for `p2p` package --------- Co-authored-by: Andy Nogueira <[email protected]>
- Loading branch information
1 parent
a24eaeb
commit c3f7ea3
Showing
15 changed files
with
370 additions
and
95 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.changelog/unreleased/improvements/1901-export-p2p-package-errors.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- `[p2p]` Export p2p package errors ([\#1901](https://github.com/cometbft/cometbft/pull/1901)) (contributes to [\#1140](https://github.com/cometbft/cometbft/issues/1140)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package conn | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ( | ||
ErrInvalidSecretConnKeySend = errors.New("send invalid secret connection key") | ||
ErrInvalidSecretConnKeyRecv = errors.New("invalid receive SecretConnection Key") | ||
ErrChallengeVerification = errors.New("challenge verification failed") | ||
) | ||
|
||
// ErrPacketWrite Packet error when writing. | ||
type ErrPacketWrite struct { | ||
Source error | ||
} | ||
|
||
func (e ErrPacketWrite) Error() string { | ||
return fmt.Sprintf("failed to write packet message: %v", e.Source) | ||
} | ||
|
||
func (e ErrPacketWrite) Unwrap() error { | ||
return e.Source | ||
} | ||
|
||
type ErrUnexpectedPubKeyType struct { | ||
Expected string | ||
Got string | ||
} | ||
|
||
func (e ErrUnexpectedPubKeyType) Error() string { | ||
return fmt.Sprintf("expected pubkey type %s, got %s", e.Expected, e.Got) | ||
} | ||
|
||
type ErrDecryptFrame struct { | ||
Source error | ||
} | ||
|
||
func (e ErrDecryptFrame) Error() string { | ||
return fmt.Sprintf("SecretConnection: failed to decrypt the frame: %v", e.Source) | ||
} | ||
|
||
func (e ErrDecryptFrame) Unwrap() error { | ||
return e.Source | ||
} | ||
|
||
type ErrPacketTooBig struct { | ||
Received int | ||
Max int | ||
} | ||
|
||
func (e ErrPacketTooBig) Error() string { | ||
return fmt.Sprintf("received message exceeds available capacity (max: %d, got: %d)", e.Max, e.Received) | ||
} | ||
|
||
type ErrChunkTooBig struct { | ||
Received int | ||
Max int | ||
} | ||
|
||
func (e ErrChunkTooBig) Error() string { | ||
return fmt.Sprintf("chunk too big (max: %d, got %d)", e.Max, e.Received) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.