misc: virtio-devices: 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
a615c809eb
commit
28e0a95450
5 changed files with 23 additions and 23 deletions
|
|
@ -76,7 +76,7 @@ unsafe impl ByteValued for VirtioPmemResp {}
|
|||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("Bad guest memory addresses: {0}")]
|
||||
GuestMemory(GuestMemoryError),
|
||||
GuestMemory(#[source] GuestMemoryError),
|
||||
#[error("Unexpected write-only descriptor")]
|
||||
UnexpectedWriteOnlyDescriptor,
|
||||
#[error("Unexpected read-only descriptor")]
|
||||
|
|
@ -88,7 +88,7 @@ enum Error {
|
|||
#[error("Invalid request")]
|
||||
InvalidRequest,
|
||||
#[error("Failed adding used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue