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 <philipp.schuster@cyberus-technology.de> On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
parent
a3dcaedf7e
commit
a615c809eb
1 changed files with 2 additions and 2 deletions
|
|
@ -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<T> = std::result::Result<T, Error>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue