use thiserror::Error as ThisError;
use crate::protocols::storm32_rc::Storm32Error;
#[derive(Debug, ThisError)]
#[non_exhaustive]
pub enum Error {
#[error("storm32: {0}")]
Storm32(#[from] Storm32Error),
#[error("serial port: {0}")]
Serial(#[from] serialport::Error),
#[error("i/o: {0}")]
Io(#[from] std::io::Error),
#[cfg(feature = "daemon")]
#[error("config: {0}")]
Config(#[from] serde_yaml_ng::Error),
#[cfg(feature = "daemon")]
#[error("json: {0}")]
Json(#[from] serde_json::Error),
#[cfg(feature = "daemon")]
#[error("mavlink write: {0}")]
MavlinkWrite(#[from] mavlink::error::MessageWriteError),
#[error("no supported gimbal protocol detected on {device}: tried {tried}")]
NotDetected {
device: String,
tried: String,
},
#[error(
"device {device} is held by another process \
(likely `turret --daemon`); send commands via the daemon's IPC \
socket, or stop the daemon first"
)]
DeviceBusy {
device: String,
},
#[error("operation not supported by {protocol}: {op}")]
Unsupported {
protocol: &'static str,
op: &'static str,
},
#[error("invalid input: {0}")]
InvalidInput(String),
#[error("daemon: {0}")]
Daemon(String),
}
pub type Result<T> = std::result::Result<T, Error>;