use crate::error::ChainProcessError; #[derive(thiserror::Error, Debug)] pub enum ProgramExecuteError { #[error("No Dispatcher Found")] DispatcherNotFound, #[error("Other error: {0}")] Other(String), } #[derive(thiserror::Error, Debug)] pub enum ProgramInternalExecuteError { #[error("No Dispatcher Found")] DispatcherNotFound, #[error("Other error: {0}")] Other(String), #[error("IO error: {0}")] IO(#[from] std::io::Error), } impl From for ProgramExecuteError { fn from(value: ProgramInternalExecuteError) -> Self { match value { ProgramInternalExecuteError::DispatcherNotFound => { ProgramExecuteError::DispatcherNotFound } ProgramInternalExecuteError::Other(s) => ProgramExecuteError::Other(s), ProgramInternalExecuteError::IO(e) => ProgramExecuteError::Other(format!("{}", e)), } } } impl From for ProgramInternalExecuteError { fn from(value: ChainProcessError) -> Self { match value { ChainProcessError::Other(s) => ProgramInternalExecuteError::Other(s), ChainProcessError::IO(error) => ProgramInternalExecuteError::IO(error), ChainProcessError::Broken(_) => ProgramInternalExecuteError::Other(format!("Broken")), } } }