misc: net_util: 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 <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-05-19 09:50:35 +02:00
committed by Rob Bradford
parent 8696bc6604
commit fd5cfb75f3
4 changed files with 25 additions and 25 deletions

View File

@@ -41,7 +41,7 @@ pub use tap::{Error as TapError, Tap};
#[derive(Error, Debug)]
pub enum Error {
#[error("Failed to create a socket: {0}")]
CreateSocket(IoError),
CreateSocket(#[source] IoError),
}
pub type Result<T> = std::result::Result<T, Error>;