Skip to main content

zlayer_registry/
error.rs

1//! Registry error types
2
3use oci_client::errors::OciDistributionError;
4use thiserror::Error;
5
6/// Registry-specific errors
7#[derive(Debug, Error)]
8pub enum RegistryError {
9    /// OCI distribution error
10    #[error("OCI distribution error: {0}")]
11    Oci(#[from] OciDistributionError),
12
13    /// Cache error
14    #[error("cache error: {0}")]
15    Cache(#[from] CacheError),
16
17    /// Image not found
18    #[error("image {image} not found in registry {registry}")]
19    NotFound { registry: String, image: String },
20
21    /// Authentication failed
22    #[error("authentication failed for registry {registry}: {reason}")]
23    AuthFailed { registry: String, reason: String },
24
25    /// Pull cancelled
26    #[error("pull cancelled for image {image}")]
27    PullCancelled { image: String },
28}
29
30/// Cache-specific errors
31#[derive(Debug, Error)]
32pub enum CacheError {
33    /// IO error
34    #[error("IO error: {0}")]
35    Io(#[from] std::io::Error),
36
37    /// Database error
38    #[error("database error: {0}")]
39    Database(String),
40
41    /// Blob not found in cache
42    #[error("blob {digest} not found in cache")]
43    NotFound { digest: String },
44
45    /// Cache corrupted
46    #[error("cache corrupted: {0}")]
47    Corrupted(String),
48
49    /// Invalid digest format
50    #[error("invalid digest format: {0}")]
51    InvalidDigest(String),
52}
53
54pub type Result<T, E = RegistryError> = std::result::Result<T, E>;