use thiserror::Error;
pub type Result<T> = std::result::Result<T, GcpError>;
#[derive(Debug, Error)]
pub enum GcpError {
#[error("Service '{0}' is not enabled. Enable the feature flag in Cargo.toml")]
ServiceNotEnabled(&'static str),
#[error("Service '{0}' is not configured. Call enable_{0}() on GcpConfig")]
ServiceNotConfigured(&'static str),
#[error("Configuration error: {0}")]
Config(String),
#[error("Authentication error: {0}")]
Auth(String),
#[error("GCP project ID not specified")]
ProjectNotSpecified,
#[error("GCP service error: {0}")]
Service(String),
#[error("Network error: {0}")]
Network(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
}
impl GcpError {
pub fn not_enabled(service: &'static str) -> Self {
Self::ServiceNotEnabled(service)
}
pub fn not_configured(service: &'static str) -> Self {
Self::ServiceNotConfigured(service)
}
}