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
@@ -40,6 +40,7 @@ use std::sync::mpsc::{channel, RecvError, SendError, Sender};
|
||||
|
||||
use micro_http::Body;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
use vm_migration::MigratableError;
|
||||
use vmm_sys_util::eventfd::EventFd;
|
||||
|
||||
@@ -56,10 +57,10 @@ use crate::vm_config::{
|
||||
use crate::Error as VmmError;
|
||||
|
||||
/// API errors are sent back from the VMM API server through the ApiResponse.
|
||||
#[derive(Debug)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ApiError {
|
||||
/// Cannot write to EventFd.
|
||||
EventFdWrite(io::Error),
|
||||
EventFdWrite(#[source] io::Error),
|
||||
|
||||
/// API request send error
|
||||
RequestSend(SendError<ApiRequest>),
|
||||
|
||||
Reference in New Issue
Block a user