abstract_interface/
error.rs
1use abstract_std::{objects::dependency::StaticDependency, AbstractError};
2use cosmwasm_std::StdError;
3use cw_orch::prelude::CwOrchError;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7pub enum AbstractInterfaceError {
8 #[error(transparent)]
9 Abstract(#[from] AbstractError),
10
11 #[error(transparent)]
12 Orch(#[from] CwOrchError),
13
14 #[cfg(feature = "interchain")]
15 #[error(transparent)]
16 OrchInterchain(#[from] cw_orch_interchain::core::InterchainError),
17
18 #[error(transparent)]
19 Std(#[from] StdError),
20
21 #[error(transparent)]
22 Instantiate2(#[from] cosmwasm_std::Instantiate2AddressError),
23
24 #[error("Abstract is not deployed on this chain {0}")]
25 NotDeployed(String),
26
27 #[error(transparent)]
28 Semver(#[from] semver::Error),
29
30 #[error("No matching module deployed {0:?}")]
31 NoMatchingModule(StaticDependency),
32}
33
34impl AbstractInterfaceError {
35 pub fn root(&self) -> &dyn std::error::Error {
36 match self {
37 AbstractInterfaceError::Orch(e) => e.root(),
38 _ => panic!("Unexpected error type"),
39 }
40 }
41
42 pub fn downcast<E>(self) -> cw_orch::anyhow::Result<E>
43 where
44 E: std::fmt::Display + std::fmt::Debug + Send + Sync + 'static,
45 {
46 match self {
47 AbstractInterfaceError::Orch(e) => e.downcast(),
48 _ => panic!("Unexpected error type"),
49 }
50 }
51}