Skip to content

Commit

Permalink
refactor: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyhyde committed Jan 3, 2025
1 parent b65a296 commit ab349ad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 41 deletions.
44 changes: 16 additions & 28 deletions gov/governance/errors.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,22 @@ import (
)

var (
errNoPermission = errors.New("[GNOSWAP-GOVERNANCE-001] caller has no permission")
errOutOfRange = errors.New("[GNOSWAP-GOVERNANCE-002] out of range for numeric value")
errInvalidInput = errors.New("[GNOSWAP-GOVERNANCE-003] invalid input")
errDataNotFound = errors.New("[GNOSWAP-GOVERNANCE-004] requested data not found")
errNotEnoughBalance = errors.New("[GNOSWAP-GOVERNANCE-005] not enough balance")
errUnableToVoteBeforeStarting = errors.New("[GNOSWAP-GOVERNANCE-006] unable to vote before starts")
errUnableToVoteAfterEnding = errors.New("[GNOSWAP-GOVERNANCE-007] unable to vote after ends")
errUnableToVoteCanceledProposal = errors.New("[GNOSWAP-GOVERNANCE-008] unable to vote for canceled proposal")
errAlreadyVoted = errors.New("[GNOSWAP-GOVERNANCE-009] can not vote twice")
errNotEnoughVotingWeight = errors.New("[GNOSWAP-GOVERNANCE-010] not enough voting power")
errAlreadyCanceledProposal = errors.New("[GNOSWAP-GOVERNANCE-011] can not cancel already canceled proposal")
errUnableToCancleVotingProposal = errors.New("[GNOSWAP-GOVERNANCE-012] unable to cancel voting proposal")
errUnableToCancelProposalWithVoterEnoughDelegated = errors.New("[GNOSWAP-GOVERNANCE-013] unable to cancel proposal with voter has enough delegation")
errTextProposalNotExecutable = errors.New("[GNOSWAP-GOVERNANCE-014] can not execute text proposal")
errUnableToExecuteProposal = errors.New("[GNOSWAP-GOVERNANCE-015] unable to execute proposal")
errBeforeProposalExecutionTime = errors.New("[GNOSWAP-GOVERNANCE-016] proposal execution time has not been reached yet")
errProposalExecutionTimeExpired = errors.New("[GNOSWAP-GOVERNANCE-017] proposal execution time expired")
errProposalQuorumNotSatisfied = errors.New("[GNOSWAP-GOVERNANCE-018] proposal quorum not met")
errMoreNoVotesThanYesVotes = errors.New("[GNOSWAP-GOVERNANCE-019] proposal hasmore no vote than yes vote")
errInvalidFunctionParameters = errors.New("[GNOSWAP-GOVERNANCE-020] invalid function parameter to execute")
errNonExecutableFunction = errors.New("[GNOSWAP-GOVERNANCE-021] not executable function")
errParseUintFailed = errors.New("[GNOSWAP-GOVERNANCE-022] parseUint internal failed")
errUnsupportedProposalType = errors.New("[GNOSWAP-GOVERNANCE-023] unsupported proposal type")
errNotRegisteredToCommunityPool = errors.New("[GNOSWAP-GOVERNANCE-024] token not registered to community pool")
errInvalidProposalType = errors.New("[GNOSWAP-GOVERNANCE-025] invalid proposal type")
errUnableToVoteOutOfPeriod = errors.New("[GNOSWAP-GOVERNANCE-026] unable to vote out of voting period")
errInvalidMessageFormat = errors.New("[GNOSWAP-GOVERNANCE-027] invalid message format")
errProposalNotPassed = errors.New("[GNOSWAP-GOVERNANCE-028] proposal not passed")
errOutOfRange = errors.New("[GNOSWAP-GOVERNANCE-001] out of range for numeric value")
errInvalidInput = errors.New("[GNOSWAP-GOVERNANCE-002] invalid input")
errDataNotFound = errors.New("[GNOSWAP-GOVERNANCE-003] requested data not found")
errNotEnoughBalance = errors.New("[GNOSWAP-GOVERNANCE-004] not enough balance")
errUnableToVoteCanceledProposal = errors.New("[GNOSWAP-GOVERNANCE-005] unable to vote for canceled proposal")
errAlreadyVoted = errors.New("[GNOSWAP-GOVERNANCE-006] can not vote twice")
errNotEnoughVotingWeight = errors.New("[GNOSWAP-GOVERNANCE-007] not enough voting power")
errAlreadyCanceledProposal = errors.New("[GNOSWAP-GOVERNANCE-008] can not cancel already canceled proposal")
errUnableToCancleVotingProposal = errors.New("[GNOSWAP-GOVERNANCE-009] unable to cancel voting proposal")
errUnableToCancelProposalWithVoterEnoughDelegated = errors.New("[GNOSWAP-GOVERNANCE-010] unable to cancel proposal with voter has enough delegation")
errTextProposalNotExecutable = errors.New("[GNOSWAP-GOVERNANCE-011] can not execute text proposal")
errUnsupportedProposalType = errors.New("[GNOSWAP-GOVERNANCE-012] unsupported proposal type")
errInvalidProposalType = errors.New("[GNOSWAP-GOVERNANCE-013] invalid proposal type")
errUnableToVoteOutOfPeriod = errors.New("[GNOSWAP-GOVERNANCE-014] unable to vote out of voting period")
errInvalidMessageFormat = errors.New("[GNOSWAP-GOVERNANCE-015] invalid message format")
errProposalNotPassed = errors.New("[GNOSWAP-GOVERNANCE-016] proposal not passed")
)

func addDetailToError(err error, detail string) string {
Expand Down
24 changes: 11 additions & 13 deletions gov/staker/errors.gno
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import (
)

var (
errNoPermission = errors.New("[GNOSWAP-GOV_STAKER-001] caller has no permission")
errNotRegistered = errors.New("[GNOSWAP-GOV_STAKER-002] not registered token")
errTransferFailed = errors.New("[GNOSWAP-GOV_STAKER-003] transfer failed")
errInvalidAmount = errors.New("[GNOSWAP-GOV_STAKER-004] invalid amount")
errNoDelegatedAmount = errors.New("[GNOSWAP-GOV_STAKER-005] zero delegated amount")
errNoDelegatedTarget = errors.New("[GNOSWAP-GOV_STAKER-006] did not delegated to that address")
errNotEnoughDelegated = errors.New("[GNOSWAP-GOV_STAKER-007] not enough delegated")
errInvalidAddress = errors.New("[GNOSWAP-GOV_STAKER-008] invalid address")
errFutureTime = errors.New("[GNOSWAP-GOV_STAKER-009] can not use future time")
errStartTimeAfterEndTime = errors.New("[GNOSWAP-GOV_STAKER-010] start time is after than end time")
errDataNotFound = errors.New("[GNOSWAP-GOV_STAKER-011] requested data not found")
errNotEnoughBalance = errors.New("[GNOSWAP-GOV_STAKER-012] not enough balance")
errLessThanMinimum = errors.New("[GNOSWAP-GOV_STAKER-013] can not delegate less than minimum amount")
errNoPermission = errors.New("[GNOSWAP-GOV_STAKER-001] caller has no permission")
errDataNotFound = errors.New("[GNOSWAP-GOV_STAKER-002] requested data not found")
errTransferFailed = errors.New("[GNOSWAP-GOV_STAKER-003] transfer failed")
errInvalidAmount = errors.New("[GNOSWAP-GOV_STAKER-004] invalid amount")
errNoDelegatedAmount = errors.New("[GNOSWAP-GOV_STAKER-005] zero delegated amount")
errNoDelegatedTarget = errors.New("[GNOSWAP-GOV_STAKER-006] did not delegated to that address")
errNotEnoughDelegated = errors.New("[GNOSWAP-GOV_STAKER-007] not enough delegated")
errInvalidAddress = errors.New("[GNOSWAP-GOV_STAKER-008] invalid address")
errFutureTime = errors.New("[GNOSWAP-GOV_STAKER-009] can not use future time")
errNotEnoughBalance = errors.New("[GNOSWAP-GOV_STAKER-010] not enough balance")
errLessThanMinimum = errors.New("[GNOSWAP-GOV_STAKER-011] can not delegate less than minimum amount")
)

func addDetailToError(err error, detail string) string {
Expand Down

0 comments on commit ab349ad

Please sign in to comment.