1use std::path::PathBuf;
2
3use oci_distribution::Reference;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7#[non_exhaustive]
9pub enum OciError {
10 #[error("No version found in annotations")]
12 NoVersion(),
13
14 #[error("No manifest found in package")]
16 NoManifest,
17
18 #[error("Invalid manifest found at {}. Try deleting your cache directory.",.0.display())]
20 InvalidManifest(PathBuf),
21
22 #[error("Reference '{0}' did not contain a tag or digest")]
23 NoTagOrDigest(String),
24 #[error("Configuration disallows fetching artifacts with the :latest tag ({0})")]
26 LatestDisallowed(String),
27
28 #[error("Could not fetch '{0}': {1}")]
30 OciFetchFailure(String, String),
31
32 #[error("Could not untar '{0}': {1}")]
34 UntarFile(String, String),
35
36 #[error("Could not push '{0}': {1}")]
38 OciPushFailure(Reference, Box<dyn std::error::Error + Send + Sync>),
39
40 #[error("Could not push manifest list '{0}': {1}")]
42 OciPushManifestListFailure(Reference, Box<dyn std::error::Error + Send + Sync>),
43
44 #[error("Could not retrieve manifest for '{0}': {1}")]
46 OciPullManifestFailure(Reference, Box<dyn std::error::Error + Send + Sync>),
47
48 #[error("Could not parse OCI URL {0}: {1}")]
50 OCIParseError(String, String),
51
52 #[error(transparent)]
54 IOError(#[from] std::io::Error),
55
56 #[error(transparent)]
58 OciDistribution(#[from] oci_distribution::errors::OciDistributionError),
59
60 #[error(transparent)]
62 JsonParseFailed(#[from] serde_json::Error),
63
64 #[error(transparent)]
66 YamlParseFailed(#[from] serde_yaml::Error),
67
68 #[error("Failed to parse the image reference: {0}")]
70 InvalidReferenceFormat(String),
71
72 #[error("Failed to pull the package: {0}")]
74 PullFailed(String),
75
76 #[error("Wick package layers must contain a title")]
78 NoTitle,
79
80 #[error("Failed to create directory '{0}': {1}")]
82 CreateDir(PathBuf, #[source] std::io::Error),
83
84 #[error("Failed to write file '{0}': {1}")]
86 WriteFile(PathBuf, #[source] std::io::Error),
87
88 #[error("Published components must be named")]
90 NoName,
91
92 #[error("Invalid layer path '{0}', layer path must contain at least one forward slash.")]
94 InvalidLayerPath(PathBuf),
95
96 #[error("Invalid cache location '{0}'")]
98 InvalidCache(wick_xdg::Error),
99
100 #[error("Failed to read downloaded package: {0}")]
102 PackageReadFailed(String),
103
104 #[error("Failed to push the package: {0}")]
106 PushFailed(String),
107
108 #[error("Refusing to overwrite {}. Set 'overwrite' to true to force.", .0.iter().map(|v|v.display().to_string()).collect::<Vec<_>>().join(", "))]
110 WouldOverwrite(Vec<PathBuf>),
111}