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

Upgrade to thiserror 2.0 #5414

Merged
merged 6 commits into from
Feb 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Remove line macros in vesting contract error type"
This reverts commit 49f937d.
octol committed Jan 31, 2025
commit 0b340f0bc2340ff12cb537735b464b98bb0c7d2e
48 changes: 24 additions & 24 deletions common/cosmwasm-smart-contracts/vesting-contract/src/error.rs
Original file line number Diff line number Diff line change
@@ -8,81 +8,81 @@ use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum VestingContractError {
#[error("VESTING: {0}")]
#[error("VESTING ({}): {0}", line!())]
Std(#[from] StdError),

#[error("VESTING: {0}")]
OverflowError(#[from] OverflowError),

#[error("VESTING: Account does not exist - {0}")]
#[error("VESTING ({}): Account does not exist - {0}", line!())]
NoAccountForAddress(String),

#[error("VESTING: Only admin can perform this action, {0} is not admin")]
#[error("VESTING ({}): Only admin can perform this action, {0} is not admin", line!())]
NotAdmin(String),

#[error("VESTING: Balance not found for existing account ({0}), this is a bug")]
#[error("VESTING ({}): Balance not found for existing account ({0}), this is a bug", line!())]
NoBalanceForAddress(String),

#[error("VESTING: Insufficient balance for address {0} -> {1}")]
#[error("VESTING ({}): Insufficient balance for address {0} -> {1}", line!())]
InsufficientBalance(String, u128),

#[error("VESTING: Insufficient spendable balance for address {0} -> {1}")]
#[error("VESTING ({}): Insufficient spendable balance for address {0} -> {1}", line!())]
InsufficientSpendable(String, u128),

#[error(
"VESTING:Only delegation owner can perform delegation actions, {0} is not the delegation owner"
)]
"VESTING ({}):Only delegation owner can perform delegation actions, {0} is not the delegation owner"
, line!())]
NotDelegate(String),

#[error("VESTING: Total vesting amount is inprobably low -> {0}, this is likely an error")]
#[error("VESTING ({}): Total vesting amount is inprobably low -> {0}, this is likely an error", line!())]
ImprobableVestingAmount(u128),

#[error("VESTING: Address {0} has already bonded a node")]
#[error("VESTING ({}): Address {0} has already bonded a node", line!())]
AlreadyBonded(String),

#[error("VESTING: Received empty funds vector")]
#[error("VESTING ({}): Received empty funds vector", line!())]
EmptyFunds,

#[error("VESTING: Received wrong denom: {0}, expected {1}")]
#[error("VESTING ({}): Received wrong denom: {0}, expected {1}", line!())]
WrongDenom(String, String),

#[error("VESTING: Received multiple denoms, expected 1")]
#[error("VESTING ({}): Received multiple denoms, expected 1", line!())]
MultipleDenoms,

#[error("VESTING: No delegations found for account {0}, mix_identity {1}")]
#[error("VESTING ({}): No delegations found for account {0}, mix_identity {1}", line!())]
NoSuchDelegation(Addr, NodeId),

#[error("VESTING: Only mixnet contract can perform this operation, got {0}")]
#[error("VESTING ({}): Only mixnet contract can perform this operation, got {0}", line!())]
NotMixnetContract(Addr),

#[error("VESTING: Calculation underflowed")]
#[error("VESTING ({}): Calculation underflowed", line!())]
Underflow,

#[error("VESTING: No bond found for account {0}")]
#[error("VESTING ({}): No bond found for account {0}", line!())]
NoBondFound(String),

#[error("VESTING: Attempted to reduce mixnode bond pledge below zero! The current pledge is {current} and we attempted to reduce it by {decrease_by}.")]
InvalidBondPledgeReduction { current: Coin, decrease_by: Coin },

#[error("VESTING: Action can only be executed by account owner -> {0}")]
#[error("VESTING ({}): Action can only be executed by account owner -> {0}", line!())]
NotOwner(String),

#[error("VESTING: Invalid address: {0}")]
#[error("VESTING ({}): Invalid address: {0}", line!())]
InvalidAddress(String),

#[error("VESTING: Account already exists: {0}")]
#[error("VESTING ({}): Account already exists: {0}", line!())]
AccountAlreadyExists(String),

#[error("VESTING: Staking account already exists: {0}")]
#[error("VESTING ({}): Staking account already exists: {0}", line!())]
StakingAccountAlreadyExists(String),

#[error("VESTING: Too few coins sent for vesting account creation, sent {sent}, need at least {need}")]
#[error("VESTING ({}): Too few coins sent for vesting account creation, sent {sent}, need at least {need}", line!())]
MinVestingFunds { sent: u128, need: u128 },

#[error("VESTING: Maximum amount of locked coins has already been pledged: {current}, cap is {cap}")]
#[error("VESTING ({}): Maximum amount of locked coins has already been pledged: {current}, cap is {cap}", line!())]
LockedPledgeCapReached { current: Uint128, cap: Uint128 },

#[error("VESTING: (Account owned by {owner} has unpopulated vesting periods!")]
#[error("VESTING: ({}: Account owned by {owner} has unpopulated vesting periods!", line!())]
UnpopulatedVestingPeriods { owner: Addr },

#[error("VESTING: Vesting account associated with {0} already exists, only addresses with not existing vesting accounts can be added as staking addresses")]