blob: fe66e22f3b7bad9fcc0782d0f424f865134a34fe (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
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<ProgramInternalExecuteError> 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<ChainProcessError> 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("Broken".to_string())
}
}
}
}
|