pub type MicrosandboxResult<T> = Result<T, MicrosandboxError>;
#[derive(Debug, thiserror::Error)]
pub enum MicrosandboxError {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("http error: {0}")]
Http(#[from] reqwest::Error),
#[error("libkrunfw not found: {0}")]
LibkrunfwNotFound(String),
#[error("database error: {0}")]
Database(#[from] sea_orm::DbErr),
#[error("invalid config: {0}")]
InvalidConfig(String),
#[error("sandbox not found: {0}")]
SandboxNotFound(String),
#[error("sandbox still running: {0}")]
SandboxStillRunning(String),
#[error("runtime error: {0}")]
Runtime(String),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("protocol error: {0}")]
Protocol(#[from] microsandbox_protocol::ProtocolError),
#[error("nix error: {0}")]
Nix(#[from] nix::errno::Errno),
#[error("exec timed out after {0:?}")]
ExecTimeout(std::time::Duration),
#[error("terminal error: {0}")]
Terminal(String),
#[error("sandbox fs error: {0}")]
SandboxFs(String),
#[error("image not found: {0}")]
ImageNotFound(String),
#[error("image in use by sandbox(es): {0}")]
ImageInUse(String),
#[error("volume not found: {0}")]
VolumeNotFound(String),
#[error("volume already exists: {0}")]
VolumeAlreadyExists(String),
#[error("image error: {0}")]
Image(#[from] microsandbox_image::ImageError),
#[error("patch failed: {0}")]
PatchFailed(String),
#[error("{0}")]
Custom(String),
}