From eb05a18c452ec6152c50c75f99e57ce769013c68 Mon Sep 17 00:00:00 2001 From: Alec Cox Date: Fri, 18 Aug 2023 13:50:14 -0700 Subject: [PATCH] add error translation to tcp errors Translation of tpc client ConnectError and Error to the appropriate embedded_io_async errors --- embassy-net/src/tcp.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index c903fb245..1a876692f 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -384,13 +384,20 @@ mod embedded_io_impls { impl embedded_io_async::Error for ConnectError { fn kind(&self) -> embedded_io_async::ErrorKind { - embedded_io_async::ErrorKind::Other + match self { + ConnectError::ConnectionReset => embedded_io_async::ErrorKind::ConnectionReset, + ConnectError::TimedOut => embedded_io_async::ErrorKind::TimedOut, + ConnectError::NoRoute => embedded_io_async::ErrorKind::NotConnected, + ConnectError::InvalidState => embedded_io_async::ErrorKind::Other, + } } } impl embedded_io_async::Error for Error { fn kind(&self) -> embedded_io_async::ErrorKind { - embedded_io_async::ErrorKind::Other + match self { + Error::ConnectionReset => embedded_io_async::ErrorKind::ConnectionReset, + } } }