mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
committed by
Rob Bradford
parent
8696bc6604
commit
fd5cfb75f3
@@ -354,27 +354,27 @@ pub enum NetQueuePairError {
|
||||
#[error("No memory configured")]
|
||||
NoMemoryConfigured,
|
||||
#[error("Error registering listener: {0}")]
|
||||
RegisterListener(io::Error),
|
||||
RegisterListener(#[source] io::Error),
|
||||
#[error("Error unregistering listener: {0}")]
|
||||
UnregisterListener(io::Error),
|
||||
UnregisterListener(#[source] io::Error),
|
||||
#[error("Error writing to the TAP device: {0}")]
|
||||
WriteTap(io::Error),
|
||||
WriteTap(#[source] io::Error),
|
||||
#[error("Error reading from the TAP device: {0}")]
|
||||
ReadTap(io::Error),
|
||||
ReadTap(#[source] io::Error),
|
||||
#[error("Error related to guest memory: {0}")]
|
||||
GuestMemory(vm_memory::GuestMemoryError),
|
||||
GuestMemory(#[source] vm_memory::GuestMemoryError),
|
||||
#[error("Returned an error while iterating through the queue: {0}")]
|
||||
QueueIteratorFailed(virtio_queue::Error),
|
||||
QueueIteratorFailed(#[source] virtio_queue::Error),
|
||||
#[error("Descriptor chain is too short")]
|
||||
DescriptorChainTooShort,
|
||||
#[error("Descriptor chain does not contain valid descriptors")]
|
||||
DescriptorChainInvalid,
|
||||
#[error("Failed to determine if queue needed notification: {0}")]
|
||||
QueueNeedsNotification(virtio_queue::Error),
|
||||
QueueNeedsNotification(#[source] virtio_queue::Error),
|
||||
#[error("Failed to enable notification on the queue: {0}")]
|
||||
QueueEnableNotification(virtio_queue::Error),
|
||||
QueueEnableNotification(#[source] virtio_queue::Error),
|
||||
#[error("Failed to add used index to the queue: {0}")]
|
||||
QueueAddUsed(virtio_queue::Error),
|
||||
QueueAddUsed(#[source] virtio_queue::Error),
|
||||
#[error("Descriptor with invalid virtio-net header")]
|
||||
DescriptorInvalidHeader,
|
||||
#[error("Invalid virtio-net header")]
|
||||
|
||||
Reference in New Issue
Block a user