use crate::capability::CheckpointFormat;
use crate::driver::VmState;
use crate::spec::VmId;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid spec: {0}")]
InvalidSpec(String),
#[error("vm {0} not found")]
NotFound(VmId),
#[error("vm {id} is {state}; expected {expected}")]
WrongState {
id: VmId,
state: VmState,
expected: &'static str,
},
#[error("checkpoint format {0} is not one this driver wrote")]
ForeignCheckpoint(CheckpointFormat),
#[error("driver `{driver}`: {message}")]
Driver {
driver: &'static str,
message: String,
#[source]
source: Option<Box<dyn std::error::Error + Send + Sync>>,
},
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("network: {0}")]
Network(String),
#[error("unavailable: {0}")]
Unavailable(String),
#[error("failed precondition: {0}")]
PreconditionFailed(String),
}
pub type Result<T> = std::result::Result<T, Error>;