From ab349adc421b2071fdd397d7729585da430d4b18 Mon Sep 17 00:00:00 2001 From: 0xTopaz Date: Fri, 3 Jan 2025 18:19:34 +0900 Subject: [PATCH] refactor: error message --- gov/governance/errors.gno | 44 ++++++++++++++------------------------- gov/staker/errors.gno | 24 ++++++++++----------- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/gov/governance/errors.gno b/gov/governance/errors.gno index 7f30545f..4f55cbe4 100644 --- a/gov/governance/errors.gno +++ b/gov/governance/errors.gno @@ -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 { diff --git a/gov/staker/errors.gno b/gov/staker/errors.gno index b595ff48..5d67cc9a 100644 --- a/gov/staker/errors.gno +++ b/gov/staker/errors.gno @@ -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 {