-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor: keyring errors #14974
Merged
Merged
refactor: keyring errors #14974
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea3791b
update: keyring error variables and use of cockroachdb/errors
JulianToledano f9755c5
update: cosmetic changes
JulianToledano 5a6300b
update: avoid fmt.Errof in keyring
JulianToledano ca78cd6
fix: use ErrUnsupportedSigningAlgo
JulianToledano f11eb72
fix: signing_algorithms_test
JulianToledano 6495569
fix: imports order
JulianToledano 7ec3f10
Merge branch 'main' into feat/keyring-refactor-phase1
JulianToledano 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
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 |
---|---|---|
@@ -1,13 +1,38 @@ | ||
package keyring | ||
|
||
import "github.com/pkg/errors" | ||
import "github.com/cockroachdb/errors" | ||
|
||
var ( | ||
// ErrUnsupportedSigningAlgo is raised when the caller tries to use a | ||
// different signing scheme than secp256k1. | ||
ErrUnsupportedSigningAlgo = errors.New("unsupported signing algo") | ||
|
||
// ErrUnsupportedLanguage is raised when the caller tries to use a | ||
// different language than english for creating a mnemonic sentence. | ||
ErrUnsupportedLanguage = errors.New("unsupported language: only english is supported") | ||
// ErrUnknownBacked is raised when the keyring backend is unknown | ||
ErrUnknownBacked = errors.New("unknown keyring backend") | ||
// ErrOverwriteKey is raised when a key cannot be overwritten | ||
ErrOverwriteKey = errors.New("cannot overwrite key") | ||
// ErrKeyAlreadyExists is raised when creating a key that already exists | ||
ErrKeyAlreadyExists = errors.Newf("key already exists") | ||
// ErrInvalidSignMode is raised when trying to sign with an invaled method | ||
ErrInvalidSignMode = errors.New("invalid sign mode, expected LEGACY_AMINO_JSON or TEXTUAL") | ||
// ErrMaxPassPhraseAttempts is raised when the maxPassphraseEntryAttempts is reached | ||
ErrMaxPassPhraseAttempts = errors.New("too many failed passphrase attempts") | ||
// ErrUnableToSerialize is raised when codec fails to serialize | ||
ErrUnableToSerialize = errors.New("unable to serialize record") | ||
// ErrOfflineSign is raised when trying to sign offline record. | ||
ErrOfflineSign = errors.New("cannot sign with offline keys") | ||
// ErrDuplicatedAddress is raised when creating a key with the same address as a key that already exists. | ||
ErrDuplicatedAddress = errors.New("duplicated address created") | ||
// ErrLedgerGenerateKey is raised when a ledger can't generate a key | ||
ErrLedgerGenerateKey = errors.New("failed to generate ledger key") | ||
// ErrNotLedgerObj is raised when record.GetLedger() returns nil. | ||
ErrNotLedgerObj = errors.New("not a ledger object") | ||
// ErrLedgerInvalidSignature is raised when ledger generates an invalid signature. | ||
ErrLedgerInvalidSignature = errors.New("Ledger generated an invalid signature. Perhaps you have multiple ledgers and need to try another one") | ||
// ErrLegacyToRecord is raised when cannot be converted to a Record | ||
ErrLegacyToRecord = errors.New("unable to convert LegacyInfo to Record") | ||
// ErrUnknownLegacyType is raised when a LegacyInfo type is unknown. | ||
ErrUnknownLegacyType = errors.New("unknown LegacyInfo type") | ||
) |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why extracting very specific errors like that. Will they be reused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this errors are returned at some point. I decided to make them public so other package can check against them and do what is convenient