#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ReactorError {
ChannelClosed,
MaxRoundsExceeded {
rounds: usize,
max_rounds: usize,
},
TcbError {
message: String,
},
InvalidState {
field: &'static str,
},
Cancelled,
TaskJoinError {
message: String,
},
}
impl core::fmt::Display for ReactorError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ReactorError::ChannelClosed => write!(f, "fact channel closed"),
ReactorError::MaxRoundsExceeded { rounds, max_rounds } => {
write!(f, "max rounds exceeded: {} > {}", rounds, max_rounds)
}
ReactorError::TcbError { message } => write!(f, "TCB error: {}", message),
ReactorError::InvalidState { field } => write!(f, "invalid state: missing {}", field),
ReactorError::Cancelled => write!(f, "reactor cancelled"),
ReactorError::TaskJoinError { message } => write!(f, "task join error: {}", message),
}
}
}
impl std::error::Error for ReactorError {}
impl From<evorule_tcb::TcbError> for ReactorError {
fn from(err: evorule_tcb::TcbError) -> Self {
ReactorError::TcbError {
message: err.to_string(),
}
}
}