Skip to content
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

[Utility] Leverage Pocket Errors in the entire codebase #556

Open
8 tasks
Olshansk opened this issue Feb 28, 2023 · 2 comments
Open
8 tasks

[Utility] Leverage Pocket Errors in the entire codebase #556

Olshansk opened this issue Feb 28, 2023 · 2 comments
Assignees
Labels
code health Nice to have code improvement core Core infrastructure - protocol related utility Utility specific changes

Comments

@Olshansk
Copy link
Member

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

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 LocalNet is still functioning correctly by following the instructions at docs/development/README.md

Creator: @Olshansk
Co-Owners: @deblasis

@Olshansk Olshansk added core Core infrastructure - protocol related utility Utility specific changes code health Nice to have code improvement labels Feb 28, 2023
@jessicadaugherty jessicadaugherty changed the title [Utility] Leverage Pocket Erros in the entire codebase [Utility] Leverage Pocket Errors in the entire codebase Mar 5, 2023
@Olshansk
Copy link
Member Author

Olshansk commented Jun 1, 2023

@adshmh Here is the ticket to standardize errors across the codebase

@h5law
Copy link
Contributor

h5law commented Jun 2, 2023

Note: I moved the errors.go file into shared/core/types/errors.go when implementing the RPC spec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Nice to have code improvement core Core infrastructure - protocol related utility Utility specific changes
Projects
Status: Backlog
Development

No branches or pull requests

3 participants