mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
a615c809eb
commit
28e0a95450
@@ -52,15 +52,15 @@ enum Error {
|
||||
#[error("Descriptor chain too short")]
|
||||
DescriptorChainTooShort,
|
||||
#[error("Failed to read from guest memory: {0}")]
|
||||
GuestMemoryRead(vm_memory::guest_memory::Error),
|
||||
GuestMemoryRead(#[source] vm_memory::guest_memory::Error),
|
||||
#[error("Failed to write to guest memory: {0}")]
|
||||
GuestMemoryWrite(vm_memory::guest_memory::Error),
|
||||
GuestMemoryWrite(#[source] vm_memory::guest_memory::Error),
|
||||
#[error("Failed to write_all output: {0}")]
|
||||
OutputWriteAll(io::Error),
|
||||
OutputWriteAll(#[source] io::Error),
|
||||
#[error("Failed to flush output: {0}")]
|
||||
OutputFlush(io::Error),
|
||||
OutputFlush(#[source] io::Error),
|
||||
#[error("Failed to add used index: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user