-
Notifications
You must be signed in to change notification settings - Fork 33
[Utility] Leverage Pocket Errors in the entire codebase #556
Copy link
Copy link
Open
Labels
code healthNice to have code improvementNice to have code improvementcoreCore infrastructure - protocol relatedCore infrastructure - protocol relatedutilityUtility specific changesUtility specific changes
Milestone
Description
Objective
Leverage pocket specific error codes throughout the entire codebase.
Origin Document
utility/types/error.go defines error codes and messages that will return descriptive identifiers to the user. These are currently only part of the utility module and cannot be used outside of it.
In #550, we moved transaction.proto from utility to shared which prevented the use of these shared errors.
type Code float64
//nolint:gosec // G101 - Not hard-coded credentials
const (
CodeOK Code = 0
CodeEmptyTransactionError Code = 2
CodeInvalidSignerError Code = 3
CodeDecodeMessageError Code = 4
// ...
}
const (
GetStakedAmountsError = "an error occurred getting the validator's amount staked"
SetValidatorStakedAmountError = "an error occurred setting the validator' amount staked"
EqualVotesError = "the votes are identical and not equivocating"
UnequalRoundsError = "the round numbers are not equal"
UnequalVoteTypesError = "the vote types are not equal"
// ...
}
// ...
func ErrUnknownParam(paramName string) Error {
return NewError(CodeUnknownParamError, fmt.Sprintf("%s: %s", UnknownParamError, paramName))
}
func ErrUnequalPublicKeys() Error {
return NewError(CodeUnequalPublicKeysError, UnequalPublicKeysError)
}
// ...Goals
- Design a way for Pocket specific error messages & codes to be utilised throughout the entire codebase
- Enable other developers to easily add new errors or modify existing ones
- Make it clear to the end user what the error is
Deliverable
- A PR that moves
errors.goinutilityinto ashareddirectory - Update to
transaction.goandtransaction_test.goinsharedthat revert it to parity with what we had before [Utility] Foundational bugs, tests, code cleanup and improvements (2/3) #550
Non-goals / Non-deliverables
- Updating all errors throughout the entire codebase to return pocket specific error codes
General issue deliverables
- Update the appropriate CHANGELOG(s)
- Update any relevant local/global README(s)
- Update relevant source code tree explanations
- Add or update any relevant or supporting mermaid diagrams
Testing Methodology
- All tests:
make test_all - LocalNet: verify a
LocalNetis still functioning correctly by following the instructions at docs/development/README.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
code healthNice to have code improvementNice to have code improvementcoreCore infrastructure - protocol relatedCore infrastructure - protocol relatedutilityUtility specific changesUtility specific changes
Type
Projects
Status
Backlog