-
Notifications
You must be signed in to change notification settings - Fork 636
chore: export p2p package errors #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andynog
merged 32 commits into
cometbft:main
from
akaladarshi:tikaryan/export-p2p-errors
Mar 18, 2024
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
67bc6ef
refactor: export p2p package errors
akaladarshi 8ff3f03
address comments
akaladarshi 5baaca3
Merge branch 'cometbft:main' into tikaryan/export-p2p-errors
akaladarshi 4a75eee
fix: linter issue
akaladarshi ae1f33a
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 4a2beb1
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 52c06e5
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 0347276
address comments
akaladarshi b6e723e
fix: ci test
akaladarshi e689291
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 4386d22
test: use custom type for comparing errors
akaladarshi dee0632
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi c472d3e
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi d31c97a
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 21b0575
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi ddd475e
Merge branch 'main' into tikaryan/export-p2p-errors
akaladarshi 1c0f1f9
Merge branch 'main' into tikaryan/export-p2p-errors
andynog 4a424aa
Merge branch 'main' into tikaryan/export-p2p-errors
andynog 8825dbc
Merge branch 'main' into tikaryan/export-p2p-errors
andynog aab6c46
Merge branch 'main' into tikaryan/export-p2p-errors
andynog b7d42f0
exported errors (#1901)
andynog 2cf0728
refactor err returned (#1901)
andynog cf99854
added exported error to unit test (#1901)
andynog 638c874
avoid prematurely returning, wrapping source error (#1901)
andynog 6a602c5
reverting some error messages changes (#1901)
andynog 7dce992
don't use any if no need to (#1901)
andynog 5e896d0
exporting errors and minor refactorings (#1901)
andynog 6356537
add changelog entry (#1901)
andynog defbbed
export errors (#1901)
andynog aed15a8
exporting errors and adding Unwrap (#1901)
andynog 6b9989b
minor refactoring in error.As check (#1901)
andynog 76e9342
merge main and fix conflicts, fix error (#1901)
andynog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.