diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-15 23:52:12 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-15 23:52:12 +0800 |
| commit | aae29170dc7ae7a8976699c4d1f7011f9f238a06 (patch) | |
| tree | b15e73d4b73b23ed41df555f962cbcdfd2b254ad /mingling_core/src/asset/chain | |
| parent | de448a04dc594f0938210abaa12de0e168f5741a (diff) | |
Remove thiserror dependency and implement error types manually
Diffstat (limited to 'mingling_core/src/asset/chain')
| -rw-r--r-- | mingling_core/src/asset/chain/error.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/mingling_core/src/asset/chain/error.rs b/mingling_core/src/asset/chain/error.rs index e5c753d..39e4f62 100644 --- a/mingling_core/src/asset/chain/error.rs +++ b/mingling_core/src/asset/chain/error.rs @@ -1,12 +1,33 @@ use crate::error::ProgramInternalExecuteError; -#[derive(thiserror::Error, Debug)] +#[derive(Debug)] pub enum ChainProcessError { - #[error("Other error: {0}")] Other(String), + IO(std::io::Error), +} + +impl std::fmt::Display for ChainProcessError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ChainProcessError::Other(s) => write!(f, "Other error: {}", s), + ChainProcessError::IO(e) => write!(f, "IO error: {}", e), + } + } +} - #[error("IO error: {0}")] - IO(#[from] std::io::Error), +impl std::error::Error for ChainProcessError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match self { + ChainProcessError::IO(e) => Some(e), + ChainProcessError::Other(_) => None, + } + } +} + +impl From<std::io::Error> for ChainProcessError { + fn from(e: std::io::Error) -> Self { + ChainProcessError::IO(e) + } } impl From<ProgramInternalExecuteError> for ChainProcessError { |
