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
@@ -83,14 +83,14 @@ enum Error {
|
||||
EventMonitorThread(#[source] vmm::Error),
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error parsing --gdb: {0}")]
|
||||
ParsingGdb(option_parser::OptionParserError),
|
||||
ParsingGdb(#[source] option_parser::OptionParserError),
|
||||
#[cfg(feature = "guest_debug")]
|
||||
#[error("Error parsing --gdb: path required")]
|
||||
BareGdb,
|
||||
#[error("Error creating log file: {0}")]
|
||||
LogFileCreation(std::io::Error),
|
||||
LogFileCreation(#[source] std::io::Error),
|
||||
#[error("Error setting up logger: {0}")]
|
||||
LoggerSetup(log::SetLoggerError),
|
||||
LoggerSetup(#[source] log::SetLoggerError),
|
||||
#[error("Failed to gracefully shutdown http api: {0}")]
|
||||
HttpApiShutdown(#[source] vmm::Error),
|
||||
#[error("Failed to create Landlock object: {0}")]
|
||||
|
||||
Reference in New Issue
Block a user