NAC_Blockchain/nac-cli-backup/src/error.rs

56 lines
1.1 KiB
Rust

use thiserror::Error;
#[derive(Error, Debug)]
#[allow(dead_code)]
pub enum CliError {
#[error("配置错误: {0}")]
Config(String),
#[error("网络错误: {0}")]
Network(String),
#[error("账户错误: {0}")]
Account(String),
#[error("交易错误: {0}")]
Transaction(String),
#[error("合约错误: {0}")]
Contract(String),
#[error("宪法错误: {0}")]
Constitution(String),
#[error("节点错误: {0}")]
Node(String),
#[error("区块错误: {0}")]
Block(String),
#[error("密码学错误: {0}")]
Crypto(String),
#[error("编码错误: {0}")]
Encoding(String),
#[error("IO错误: {0}")]
Io(#[from] std::io::Error),
#[error("JSON错误: {0}")]
Json(#[from] serde_json::Error),
#[error("YAML错误: {0}")]
Yaml(#[from] serde_yaml::Error),
#[error("TOML错误: {0}")]
Toml(#[from] toml::de::Error),
#[error("HTTP错误: {0}")]
Http(#[from] reqwest::Error),
#[error("其他错误: {0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, CliError>;