cycles-quartz/apps/mtcs/contracts/cw-tee-mtcs/src/error.rs

55 lines
1.1 KiB
Rust
Raw Normal View History

2023-11-29 21:13:20 +00:00
use cosmwasm_std::StdError;
2024-05-07 22:06:09 +00:00
use cw20_base::ContractError as Cw20ContractError;
2023-12-05 17:03:43 +00:00
use hex::FromHexError;
use k256::ecdsa::Error as K256Error;
use quartz_common::contract::error::Error as QuartzError;
2023-11-29 21:13:20 +00:00
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),
2024-03-19 21:19:38 +00:00
#[error("{0}")]
Quartz(#[from] QuartzError),
2023-11-29 21:13:20 +00:00
#[error("Unauthorized")]
Unauthorized,
2023-11-29 22:09:57 +00:00
#[error("Liquidity source not found")]
LiquiditySourceNotFound,
2024-03-19 21:19:38 +00:00
#[error("Duplicate entry found")]
DuplicateEntry,
#[error("No entry found")]
NoLiquiditySourcesFound,
2023-12-05 17:03:43 +00:00
#[error("Not Secp256K1")]
K256(K256Error),
2023-12-22 13:10:51 +00:00
2023-12-05 17:03:43 +00:00
#[error("Invalid hex")]
2024-03-19 21:19:38 +00:00
Hex(#[from] FromHexError),
2023-12-05 17:03:43 +00:00
2023-12-22 13:10:51 +00:00
#[error("Invalid length")]
BadLength,
2024-05-07 22:06:09 +00:00
#[error("Cw20 error: {0}")]
Cw20(Cw20ContractError),
#[error("Unsupported liquidity source")]
UnsupportedLiquiditySource,
2023-11-29 21:13:20 +00:00
}
2023-12-05 17:03:43 +00:00
2023-12-22 13:10:51 +00:00
impl From<K256Error> for ContractError {
2023-12-05 17:03:43 +00:00
fn from(e: K256Error) -> Self {
2024-03-19 21:19:38 +00:00
Self::K256(e)
2023-12-05 17:03:43 +00:00
}
}
2024-05-07 22:06:09 +00:00
impl From<Cw20ContractError> for ContractError {
fn from(e: Cw20ContractError) -> Self {
Self::Cw20(e)
}
}