1use std::path::PathBuf;
4
5use arcbox_error::CommonError;
6use thiserror::Error;
7
8pub type Result<T> = std::result::Result<T, OciError>;
10
11#[derive(Debug, Error)]
13pub enum OciError {
14 #[error(transparent)]
16 Common(#[from] CommonError),
17
18 #[error("invalid OCI version: {0}")]
20 InvalidVersion(String),
21
22 #[error("missing required field: {0}")]
24 MissingField(&'static str),
25
26 #[error("invalid configuration: {0}")]
28 InvalidConfig(String),
29
30 #[error("bundle not found: {0}")]
32 BundleNotFound(PathBuf),
33
34 #[error("config.json not found in bundle: {0}")]
36 ConfigNotFound(PathBuf),
37
38 #[error("invalid bundle structure: {0}")]
40 InvalidBundle(String),
41
42 #[error("container not found: {0}")]
44 ContainerNotFound(String),
45
46 #[error("hook execution failed: {path} - {reason}")]
48 HookFailed { path: PathBuf, reason: String },
49
50 #[error("hook timeout: {path} (timeout: {timeout}s)")]
52 HookTimeout { path: PathBuf, timeout: u32 },
53
54 #[error("invalid path: {0}")]
56 InvalidPath(String),
57
58 #[error("JSON error: {0}")]
60 Json(#[from] serde_json::Error),
61}
62
63impl From<std::io::Error> for OciError {
64 fn from(err: std::io::Error) -> Self {
65 Self::Common(CommonError::from(err))
66 }
67}