1use autd3_core::link::LinkError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5#[non_exhaustive]
6pub enum AUTDProtoBufError {
7 #[error("{0}")]
10 Status(String),
11 #[error("{0}")]
12 SendError(String),
13 #[error("{0}")]
14 TransportError(#[from] tonic::transport::Error),
15}
16
17impl From<tonic::Status> for AUTDProtoBufError {
20 fn from(e: tonic::Status) -> Self {
21 AUTDProtoBufError::Status(e.to_string())
22 }
23}
24
25impl From<AUTDProtoBufError> for tonic::Status {
26 fn from(e: AUTDProtoBufError) -> Self {
27 tonic::Status::internal(e.to_string())
28 }
29}
30
31impl<T> From<std::sync::mpsc::SendError<T>> for AUTDProtoBufError {
32 fn from(e: std::sync::mpsc::SendError<T>) -> Self {
33 AUTDProtoBufError::SendError(e.to_string())
34 }
35}
36
37impl From<AUTDProtoBufError> for autd3_core::link::LinkError {
38 fn from(e: AUTDProtoBufError) -> Self {
39 LinkError::new(e)
40 }
41}
42
43