use std::path::PathBuf;
use arcbox_error::CommonError;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, OciError>;
#[derive(Debug, Error)]
pub enum OciError {
#[error(transparent)]
Common(#[from] CommonError),
#[error("invalid OCI version: {0}")]
InvalidVersion(String),
#[error("missing required field: {0}")]
MissingField(&'static str),
#[error("invalid configuration: {0}")]
InvalidConfig(String),
#[error("bundle not found: {0}")]
BundleNotFound(PathBuf),
#[error("config.json not found in bundle: {0}")]
ConfigNotFound(PathBuf),
#[error("invalid bundle structure: {0}")]
InvalidBundle(String),
#[error("container not found: {0}")]
ContainerNotFound(String),
#[error("hook execution failed: {path} - {reason}")]
HookFailed { path: PathBuf, reason: String },
#[error("hook timeout: {path} (timeout: {timeout}s)")]
HookTimeout { path: PathBuf, timeout: u32 },
#[error("invalid path: {0}")]
InvalidPath(String),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
}
impl From<std::io::Error> for OciError {
fn from(err: std::io::Error) -> Self {
Self::Common(CommonError::from(err))
}
}