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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use cosmwasm_std::Addr;
use cw_asset::AssetError;
use os::{objects::AssetEntry, AbstractOsError};
use std::fmt::{Display, Formatter};
use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub struct EndpointError {
#[source]
source: AbstractSdkError,
module_id: String,
}
impl Display for EndpointError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Error in {} - {}", self.module_id, self.source)
}
}
#[derive(Error, Debug, PartialEq)]
pub enum AbstractSdkError {
#[error("Abstract OS error in the sdk: {0}")]
AbstractOs(#[from] AbstractOsError),
#[error("Std error encountered in sdk: {0}")]
Std(#[from] cosmwasm_std::StdError),
#[error("Asset error encountered in sdk while handling assets: {0}")]
Asset(#[from] AssetError),
#[error("Missing handler for {endpoint}")]
MissingHandler { endpoint: String },
#[error("Missing module {module}")]
MissingModule { module: String },
#[error("Module {module} is not a dependency of this contract.")]
MissingDependency { module: String },
#[error("Asset {asset} is not registered on your OS. Please register it first.")]
MissingAsset { asset: AssetEntry },
#[error("Address {0} is not the Manager of OS {1}.")]
NotManager(Addr, u32),
#[error("Address {0} is not the Proxy of OS {1}.")]
NotProxy(Addr, u32),
#[error("Unknown OS id {os_id} on version control {version_control_addr}. Please ensure that you are using the correct OS id and version control address.")]
UnknownOsId {
os_id: u32,
version_control_addr: Addr,
},
#[error("Failed to query OS id on contract {contract_addr}. Please ensure that the contract is a Manager or Proxy contract.")]
FailedToQueryOsId { contract_addr: Addr },
#[error("Module {module} not found in version registry {registry_addr}.")]
ModuleNotFound { module: String, registry_addr: Addr },
#[error("IBC callback called by {caller} instead of IBC client {client_addr}.")]
CallbackNotCalledByIbcClient {
caller: Addr,
client_addr: Addr,
module: String,
},
#[error("Admin of proxy {proxy_addr} is not set.")]
AdminNotSet { proxy_addr: Addr },
}
impl AbstractSdkError {
pub fn generic_err(msg: impl Into<String>) -> Self {
AbstractSdkError::Std(cosmwasm_std::StdError::generic_err(msg))
}
}