abstract_version_control/
error.rs

1use abstract_sdk::AbstractSdkError;
2use abstract_std::{
3    objects::{module::ModuleInfo, namespace::Namespace, validation::ValidationError, AccountId},
4    AbstractError,
5};
6use cosmwasm_std::{Addr, Coin, StdError};
7use thiserror::Error;
8
9#[derive(Error, Debug, PartialEq)]
10pub enum VCError {
11    #[error("{0}")]
12    Std(#[from] StdError),
13
14    #[error("{0}")]
15    Abstract(#[from] AbstractError),
16
17    #[error("{0}")]
18    AbstractSdk(#[from] AbstractSdkError),
19
20    #[error("{0}")]
21    Validation(#[from] ValidationError),
22
23    #[error("{0}")]
24    Ownership(#[from] cw_ownable::OwnershipError),
25
26    #[error("Semver parsing error: {0}")]
27    SemVer(String),
28
29    #[error("Module {0} does not have a stored module reference")]
30    ModuleNotFound(ModuleInfo),
31
32    #[error("Module {0} is in both approve and reject")]
33    InvalidApproveList(ModuleInfo),
34
35    #[error("Module {0} cannot be updated")]
36    NotUpdateableModule(ModuleInfo),
37
38    #[error("Account ID {} is not in version control register", id)]
39    UnknownAccountId { id: AccountId },
40
41    #[error("Namespace {} is not in version control register", namespace)]
42    UnknownNamespace { namespace: Namespace },
43
44    #[error("Account owner mismatch sender: {}, owner: {}", sender, owner)]
45    AccountOwnerMismatch { sender: Addr, owner: Addr },
46
47    #[error("Account with ID {} has no owner", account_id)]
48    NoAccountOwner { account_id: AccountId },
49
50    #[error("Namespace {} is already occupied by account {}", namespace, id)]
51    NamespaceOccupied { namespace: String, id: AccountId },
52
53    #[error("Exceeds namespace limit: {}, current: {}", limit, current)]
54    ExceedsNamespaceLimit { limit: usize, current: usize },
55
56    #[error(
57        "Decreasing namespace limit is not allowed: {}, current: {}",
58        limit,
59        current
60    )]
61    DecreaseNamespaceLimit { limit: u32, current: u32 },
62
63    #[error("As namespace owner you can only yank a module, not remove it.")]
64    OnlyYankAllowed,
65
66    #[error("The admin of an adapter must be None")]
67    AdminMustBeNone,
68
69    #[error("No action specified")]
70    NoAction,
71
72    #[error("Account {0} already exists")]
73    AccountAlreadyExists(AccountId),
74
75    #[error("Invalid fee payment sent. Expected {}, sent {:?}", expected, sent)]
76    InvalidFeePayment { expected: Coin, sent: Vec<Coin> },
77
78    #[error("Initialization funds can only be specified for apps and standalone modules")]
79    RedundantInitFunds {},
80
81    #[error("Only account factory is allowed to add new accounts")]
82    NotAccountFactory {},
83}
84
85impl From<cw_semver::Error> for VCError {
86    fn from(err: cw_semver::Error) -> Self {
87        Self::SemVer(err.to_string())
88    }
89}