diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index 0918cdb5..96bf9e18 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -261,7 +261,14 @@ impl fmt::Display for ReadExactError { } } -impl core::error::Error for ReadExactError {} +impl core::error::Error for ReadExactError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + Self::UnexpectedEof => None, + Self::Other(error) => Some(error), + } + } +} /// Errors that could be returned by `Write` on `&mut [u8]`. #[derive(Debug, Copy, Clone, Eq, PartialEq)] @@ -294,7 +301,14 @@ impl fmt::Display for WriteFmtError { } } -impl core::error::Error for WriteFmtError {} +impl core::error::Error for WriteFmtError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { + match self { + Self::FmtError => None, + Self::Other(error) => Some(error), + } + } +} /// Blocking reader. ///