Skip to main content

microvm_runtime/
error.rs

1use thiserror::Error;
2
3/// Convenience alias used throughout runtime providers.
4pub type VmRuntimeResult<T> = Result<T, VmRuntimeError>;
5
6/// Errors that can occur during microVM lifecycle or query operations.
7#[derive(Debug, Error)]
8pub enum VmRuntimeError {
9    /// Attempted to create a VM with an identifier that is already in use.
10    #[error("vm '{0}' already exists")]
11    VmAlreadyExists(String),
12
13    /// Referenced a VM identifier that does not exist.
14    #[error("vm '{0}' not found")]
15    VmNotFound(String),
16
17    /// A lifecycle transition was requested that is not valid from the current state.
18    #[error("invalid vm transition for '{vm_id}': {from} -> {to}")]
19    InvalidTransition {
20        vm_id: String,
21        from: String,
22        to: &'static str,
23    },
24
25    /// Attempted to create a snapshot with an identifier that already exists on the VM.
26    #[error("snapshot '{snapshot_id}' already exists for vm '{vm_id}'")]
27    SnapshotAlreadyExists { vm_id: String, snapshot_id: String },
28
29    /// Internal lock was poisoned by a panicking thread.
30    #[error("provider state lock poisoned")]
31    StatePoisoned,
32
33    /// Backend is not supported in the current build/config.
34    #[error("backend unsupported: {0}")]
35    Unsupported(String),
36}