mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: arch/riscv64: 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
d1a406143d
commit
a212343908
+26
-26
@@ -41,81 +41,81 @@ pub enum Error {
|
||||
/// Missing restore source_url parameter.
|
||||
ParseRestoreSourceUrlMissing,
|
||||
/// Error parsing CPU options
|
||||
ParseCpus(OptionParserError),
|
||||
ParseCpus(#[source] OptionParserError),
|
||||
/// Invalid CPU features
|
||||
InvalidCpuFeatures(String),
|
||||
/// Error parsing memory options
|
||||
ParseMemory(OptionParserError),
|
||||
ParseMemory(#[source] OptionParserError),
|
||||
/// Error parsing memory zone options
|
||||
ParseMemoryZone(OptionParserError),
|
||||
ParseMemoryZone(#[source] OptionParserError),
|
||||
/// Missing 'id' from memory zone
|
||||
ParseMemoryZoneIdMissing,
|
||||
/// Error parsing rate-limiter group options
|
||||
ParseRateLimiterGroup(OptionParserError),
|
||||
ParseRateLimiterGroup(#[source] OptionParserError),
|
||||
/// Error parsing disk options
|
||||
ParseDisk(OptionParserError),
|
||||
ParseDisk(#[source] OptionParserError),
|
||||
/// Error parsing network options
|
||||
ParseNetwork(OptionParserError),
|
||||
ParseNetwork(#[source] OptionParserError),
|
||||
/// Error parsing RNG options
|
||||
ParseRng(OptionParserError),
|
||||
ParseRng(#[source] OptionParserError),
|
||||
/// Error parsing balloon options
|
||||
ParseBalloon(OptionParserError),
|
||||
ParseBalloon(#[source] OptionParserError),
|
||||
/// Error parsing filesystem parameters
|
||||
ParseFileSystem(OptionParserError),
|
||||
ParseFileSystem(#[source] OptionParserError),
|
||||
/// Error parsing persistent memory parameters
|
||||
ParsePersistentMemory(OptionParserError),
|
||||
ParsePersistentMemory(#[source] OptionParserError),
|
||||
/// Failed parsing console
|
||||
ParseConsole(OptionParserError),
|
||||
ParseConsole(#[source] OptionParserError),
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
/// Failed parsing debug-console
|
||||
ParseDebugConsole(OptionParserError),
|
||||
ParseDebugConsole(#[source] OptionParserError),
|
||||
/// No mode given for console
|
||||
ParseConsoleInvalidModeGiven,
|
||||
/// Failed parsing device parameters
|
||||
ParseDevice(OptionParserError),
|
||||
ParseDevice(#[source] OptionParserError),
|
||||
/// Missing path from device,
|
||||
ParseDevicePathMissing,
|
||||
/// Failed parsing vsock parameters
|
||||
ParseVsock(OptionParserError),
|
||||
ParseVsock(#[source] OptionParserError),
|
||||
/// Failed parsing restore parameters
|
||||
ParseRestore(OptionParserError),
|
||||
ParseRestore(#[source] OptionParserError),
|
||||
/// Failed parsing SGX EPC parameters
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
ParseSgxEpc(OptionParserError),
|
||||
ParseSgxEpc(#[source] OptionParserError),
|
||||
/// Missing 'id' from SGX EPC section
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
ParseSgxEpcIdMissing,
|
||||
/// Failed parsing NUMA parameters
|
||||
ParseNuma(OptionParserError),
|
||||
ParseNuma(#[source] OptionParserError),
|
||||
/// Failed validating configuration
|
||||
Validation(ValidationError),
|
||||
Validation(#[source] ValidationError),
|
||||
#[cfg(feature = "sev_snp")]
|
||||
/// Failed parsing SEV-SNP config
|
||||
ParseSevSnp(OptionParserError),
|
||||
ParseSevSnp(#[source] OptionParserError),
|
||||
#[cfg(feature = "tdx")]
|
||||
/// Failed parsing TDX config
|
||||
ParseTdx(OptionParserError),
|
||||
ParseTdx(#[source] OptionParserError),
|
||||
#[cfg(feature = "tdx")]
|
||||
/// No TDX firmware
|
||||
FirmwarePathMissing,
|
||||
/// Failed parsing userspace device
|
||||
ParseUserDevice(OptionParserError),
|
||||
ParseUserDevice(#[source] OptionParserError),
|
||||
/// Missing socket for userspace device
|
||||
ParseUserDeviceSocketMissing,
|
||||
/// Error parsing pci segment options
|
||||
ParsePciSegment(OptionParserError),
|
||||
ParsePciSegment(#[source] OptionParserError),
|
||||
/// Failed parsing platform parameters
|
||||
ParsePlatform(OptionParserError),
|
||||
ParsePlatform(#[source] OptionParserError),
|
||||
/// Failed parsing vDPA device
|
||||
ParseVdpa(OptionParserError),
|
||||
ParseVdpa(#[source] OptionParserError),
|
||||
/// Missing path for vDPA device
|
||||
ParseVdpaPathMissing,
|
||||
/// Failed parsing TPM device
|
||||
ParseTpm(OptionParserError),
|
||||
ParseTpm(#[source] OptionParserError),
|
||||
/// Missing path for TPM device
|
||||
ParseTpmPathMissing,
|
||||
/// Error parsing Landlock rules
|
||||
ParseLandlockRules(OptionParserError),
|
||||
ParseLandlockRules(#[source] OptionParserError),
|
||||
/// Missing fields in Landlock rules
|
||||
ParseLandlockMissingFields,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user