#[derive(Debug)]
pub enum SimError {
NotConnected(String),
NoSimRunning,
InvalidHeader(String),
Io(std::io::Error),
}
impl std::fmt::Display for SimError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SimError::NotConnected(msg) => write!(f, "Not connected: {}", msg),
SimError::NoSimRunning => write!(f, "No simulator is currently running"),
SimError::InvalidHeader(msg) => write!(f, "Invalid header: {}", msg),
SimError::Io(e) => write!(f, "IO error: {}", e),
}
}
}
impl std::error::Error for SimError {}
impl From<std::io::Error> for SimError {
fn from(e: std::io::Error) -> Self {
SimError::Io(e)
}
}