mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: vmm: 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
5db92f79bf
commit
fff62d9302
@@ -114,7 +114,7 @@ pub enum Error {
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[error("Cannot load the UEFI binary in memory: {0:?}")]
|
||||
UefiLoad(arch::aarch64::uefi::Error),
|
||||
UefiLoad(#[source] arch::aarch64::uefi::Error),
|
||||
|
||||
#[error("Cannot load the initramfs into memory")]
|
||||
InitramfsLoad,
|
||||
@@ -136,7 +136,7 @@ pub enum Error {
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
#[error("Cannot enable interrupt controller: {0:?}")]
|
||||
EnableInterruptController(interrupt_controller::Error),
|
||||
EnableInterruptController(#[source] interrupt_controller::Error),
|
||||
|
||||
#[error("VM state is poisoned")]
|
||||
PoisonedState,
|
||||
@@ -277,7 +277,7 @@ pub enum Error {
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
#[error("Error allocating TDVF memory: {0:?}")]
|
||||
AllocatingTdvfMemory(crate::memory_manager::Error),
|
||||
AllocatingTdvfMemory(#[source] crate::memory_manager::Error),
|
||||
|
||||
#[cfg(feature = "tdx")]
|
||||
#[error("Error enabling TDX VM: {0}")]
|
||||
@@ -301,7 +301,7 @@ pub enum Error {
|
||||
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error debugging VM: {0:?}")]
|
||||
Debug(DebuggableError),
|
||||
Debug(#[source] DebuggableError),
|
||||
|
||||
#[error("Error spawning kernel loading thread")]
|
||||
KernelLoadThreadSpawn(#[source] std::io::Error),
|
||||
|
||||
Reference in New Issue
Block a user