use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum SecretError {
#[error("Invalid secret URI '{uri}': {reason}")]
InvalidUri { uri: String, reason: String },
#[error("Secret not found: {0}")]
NotFound(String),
#[error("Secret backend '{backend}' not available (feature not enabled)")]
BackendDisabled { backend: String },
#[error("{backend} error: {message}")]
BackendError { backend: String, message: String },
#[error("Access denied to secret: {0}")]
AccessDenied(String),
#[error("Failed to read file '{path}': {message}")]
FileError { path: PathBuf, message: String },
#[error("Environment variable '{var}' not set")]
EnvNotSet { var: String },
}
impl SecretError {
pub fn invalid_uri(uri: impl Into<String>, reason: impl Into<String>) -> Self {
Self::InvalidUri {
uri: uri.into(),
reason: reason.into(),
}
}
pub fn backend(backend: impl Into<String>, message: impl Into<String>) -> Self {
Self::BackendError {
backend: backend.into(),
message: message.into(),
}
}
pub fn disabled(backend: impl Into<String>) -> Self {
Self::BackendDisabled {
backend: backend.into(),
}
}
}