From a615c809eb1704e45333ffc03e29f63ba2a8c952 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Mon, 19 May 2025 09:51:17 +0200 Subject: [PATCH] misc: vsock: streamline #[source] and Error This streamlines the code base to follow best practices for error handling in Rust: Each error struct implements std::error::Error (most due via thiserror::Error derive macro) and sets its source accordingly. This allows future work that nicely prints the error chains, for example. So far, the convention is that each error prints its sub error as part of its Display::fmt() impl. Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com --- virtio-devices/src/vsock/csm/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtio-devices/src/vsock/csm/mod.rs b/virtio-devices/src/vsock/csm/mod.rs index 01c8aac84..9e02ac854 100644 --- a/virtio-devices/src/vsock/csm/mod.rs +++ b/virtio-devices/src/vsock/csm/mod.rs @@ -33,10 +33,10 @@ pub enum Error { TxBufFull, /// An I/O error occurred, when attempting to flush the connection TX buffer. #[error("Error flushing TX buffer: {0}")] - TxBufFlush(std::io::Error), + TxBufFlush(#[source] std::io::Error), /// An I/O error occurred, when attempting to write data to the host-side stream. #[error("Error writing to host side stream: {0}")] - StreamWrite(std::io::Error), + StreamWrite(#[source] std::io::Error), } type Result = std::result::Result;