use autd3_core::link::LinkError;
use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum AUTDProtoBufError {
#[error("{0}")]
Status(String),
#[error("{0}")]
SendError(String),
#[error("{0}")]
TransportError(#[from] tonic::transport::Error),
}
impl From<tonic::Status> for AUTDProtoBufError {
fn from(e: tonic::Status) -> Self {
AUTDProtoBufError::Status(e.to_string())
}
}
impl From<AUTDProtoBufError> for tonic::Status {
fn from(e: AUTDProtoBufError) -> Self {
tonic::Status::internal(e.to_string())
}
}
impl<T> From<std::sync::mpsc::SendError<T>> for AUTDProtoBufError {
fn from(e: std::sync::mpsc::SendError<T>) -> Self {
AUTDProtoBufError::SendError(e.to_string())
}
}
impl From<AUTDProtoBufError> for autd3_core::link::LinkError {
fn from(e: AUTDProtoBufError) -> Self {
LinkError::new(e)
}
}