abstract_std/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use cosmwasm_std::StdError;
use cw_asset::AssetError;
use semver::Version;
use thiserror::Error;

use crate::objects::{ans_host::AnsHostError, registry::RegistryError};

/// Wrapper error for the Abstract framework.
#[derive(Error, Debug, PartialEq)]
pub enum AbstractError {
    #[error("Std error encountered while handling account object: {0}")]
    Std(#[from] StdError),

    #[error(transparent)]
    Asset(#[from] AssetError),

    #[error(transparent)]
    RegistryError(#[from] RegistryError),

    #[error(transparent)]
    AnsHostError(#[from] AnsHostError),

    #[error(transparent)]
    Instantiate2AddressError(#[from] cosmwasm_std::Instantiate2AddressError),

    #[error("Semver error encountered while handling account object: {0}")]
    Semver(String),

    #[error("Entry {actual} should be formatted as {expected}")]
    EntryFormattingError { actual: String, expected: String },

    #[error("Object {object} should be formatted {expected} but is {actual}")]
    FormattingError {
        object: String,
        expected: String,
        actual: String,
    },

    #[error("Cannot downgrade contract {} from {} to {}", contract, from, to)]
    CannotDowngradeContract {
        contract: String,
        from: Version,
        to: Version,
    },

    #[error("Cannot rename contract from {} to {}", from, to)]
    ContractNameMismatch { from: String, to: String },

    #[error("App {0} not installed on Account")]
    AppNotInstalled(String),

    #[error("version for {0} in missing")]
    MissingVersion(String),

    #[error("assertion: {0}")]
    Assert(String),

    //fee error
    #[error("fee error: {0}")]
    Fee(String),

    #[error("The version or name of this module was not consistent between its stores (cw2: {cw2} and abstract module data: {module}).")]
    UnequalModuleData { cw2: String, module: String },

    #[error("Cannot Skip module version {contract} from {from} to {to}")]
    CannotSkipVersion {
        contract: String,
        from: Version,
        to: Version,
    },
}

impl From<semver::Error> for AbstractError {
    fn from(err: semver::Error) -> Self {
        AbstractError::Semver(err.to_string())
    }
}