#![allow(missing_docs)]
use core::{objects::AssetEntry, AbstractError};
use cosmwasm_std::Addr;
use cw_asset::AssetError;
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 Account error in the sdk: {0}")]
    Abstract(#[from] AbstractError),
    #[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 Account. Please register it first.")]
    MissingAsset { asset: AssetEntry },
    #[error("Address {0} is not the Manager of Account {1}.")]
    NotManager(Addr, u32),
    #[error("Address {0} is not the Proxy of Account {1}.")]
    NotProxy(Addr, u32),
    #[error("Unknown Account id {account_id} on version control {version_control_addr}. Please ensure that you are using the correct Account id and version control address.")]
    UnknownAccountId {
        account_id: u32,
        version_control_addr: Addr,
    },
    #[error("Failed to query Account id on contract {contract_addr}. Please ensure that the contract is a Manager or Proxy contract.")]
    FailedToQueryAccountId { 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))
    }
}