use crate::robot::logger::Record;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum FrankaException {
#[error("{error}")]
ControlException {
log: Option<Vec<Record>>,
error: String,
},
#[error("Incompatible library version: Robot has version {server_version:?} and libfranka-rs has {library_version:?}")]
IncompatibleLibraryVersionError {
server_version: u16,
library_version: u16,
},
#[error("Trying to send motion command, but no motion generator running!")]
NoMotionGeneratorRunningError,
#[error("Trying to send control command, but no controller generator running!")]
NoControllerRunningError,
#[error("Trying to send partial command!")]
PartialCommandError,
#[error("{message:?}")]
NetworkException { message: String },
#[error("{message:?}")]
CommandException { message: String },
#[error("{message:?}")]
ModelException { message: String },
#[error("{message:?}")]
RealTimeException { message: String },
}
pub(crate) fn create_command_exception(message: &'static str) -> FrankaException {
FrankaException::CommandException {
message: message.to_string(),
}
}
pub type FrankaResult<T> = Result<T, FrankaException>;