robot_control/error.rs
1//! Error types for the robot-control crate.
2
3use thiserror::Error;
4
5/// Errors that can occur when interacting with a motor driver.
6#[derive(Debug, Error)]
7pub enum MotorError {
8 /// An I2C bus operation failed.
9 #[error("I2C error: {0}")]
10 I2c(String),
11
12 /// A PWM controller operation failed.
13 #[error("PWM error: {0}")]
14 Pwm(String),
15
16 /// The motor driver failed to initialize.
17 #[error("initialization failed: {0}")]
18 Init(String),
19}
20
21/// Errors that can occur when controlling the robot.
22#[derive(Debug, Error)]
23pub enum RobotError {
24 /// A motor driver operation failed.
25 #[error(transparent)]
26 Motor(#[from] MotorError),
27
28 /// The robot has already been shut down.
29 #[error("robot has been shut down")]
30 Shutdown,
31}