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
+10
-5
@@ -9,6 +9,7 @@ use std::io::Write;
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use hypervisor::arch::x86::{DescriptorTable, SegmentRegister};
|
||||
use linux_loader::elf;
|
||||
use thiserror::Error;
|
||||
use vm_memory::ByteValued;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -33,12 +34,16 @@ pub struct DumpState {
|
||||
pub file: Option<File>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum GuestDebuggableError {
|
||||
Coredump(anyhow::Error),
|
||||
CoredumpFile(std::io::Error),
|
||||
Pause(vm_migration::MigratableError),
|
||||
Resume(vm_migration::MigratableError),
|
||||
#[error("coredump: {0}")]
|
||||
Coredump(#[source] anyhow::Error),
|
||||
#[error("coredump file: {0}")]
|
||||
CoredumpFile(#[source] std::io::Error),
|
||||
#[error("Failed to pause: {0}")]
|
||||
Pause(#[source] vm_migration::MigratableError),
|
||||
#[error("Failed to resume: {0}")]
|
||||
Resume(#[source] vm_migration::MigratableError),
|
||||
}
|
||||
|
||||
pub trait GuestDebuggable: vm_migration::Pausable {
|
||||
|
||||
Reference in New Issue
Block a user