Skip to main content

zlayer_types/secrets/
error.rs

1//! Error type for secrets operations.
2//!
3//! Lifted into `zlayer-types` so cross-crate consumers (`zlayer-api`,
4//! `zlayer-agent`, the CLI) can name secrets errors without depending on
5//! `zlayer-secrets`. The `zlayer-secrets` crate re-exports these for
6//! backward compatibility.
7
8use thiserror::Error;
9
10/// Error type for secrets operations.
11#[derive(Error, Debug)]
12pub enum SecretsError {
13    #[error("Secret not found: {name}")]
14    NotFound { name: String },
15
16    #[error("Access denied to secret: {name}")]
17    AccessDenied { name: String },
18
19    #[error("Encryption error: {0}")]
20    Encryption(String),
21
22    #[error("Decryption error: {0}")]
23    Decryption(String),
24
25    #[error("Storage error: {0}")]
26    Storage(String),
27
28    #[error("Invalid secret name: {name}")]
29    InvalidName { name: String },
30
31    #[error("Secret already exists: {name}")]
32    AlreadyExists { name: String },
33
34    #[error("Provider error: {0}")]
35    Provider(String),
36}
37
38/// Convenience `Result` alias parameterised over [`SecretsError`].
39pub type Result<T> = std::result::Result<T, SecretsError>;