use thiserror::Error;
#[derive(Debug, Clone, Error)]
pub enum ProviderError {
#[error("Resource not found: {resource_type} with id '{id}' in tenant '{tenant_id}'")]
ResourceNotFound {
resource_type: String,
id: String,
tenant_id: String,
},
#[error(
"Duplicate attribute '{attribute}' with value '{value}' for {resource_type} in tenant '{tenant_id}'"
)]
DuplicateAttribute {
resource_type: String,
attribute: String,
value: String,
tenant_id: String,
},
#[error("Invalid resource data: {message}")]
InvalidData {
message: String,
},
#[error("Query error: {message}")]
QueryError {
message: String,
},
#[error("Storage error: {message}")]
Storage {
message: String,
},
#[error("Internal error: {message}")]
Internal {
message: String,
},
#[error("Invalid input: {message}")]
InvalidInput {
message: String,
},
#[error("Resource not found: {resource_type} with id '{id}'")]
NotFound {
resource_type: String,
id: String,
},
#[error("Precondition failed: {message}")]
PreconditionFailed {
message: String,
},
#[error(
"Duplicate resource: {resource_type} with userName '{username}' already exists in tenant '{tenant_id}'"
)]
DuplicateUserName {
resource_type: String,
username: String,
tenant_id: String,
},
#[error("Patch operation failed: {message}")]
PatchOperationFailed {
message: String,
},
#[error("Version conflict: {conflict}")]
VersionConflict {
#[from]
conflict: crate::resource::version::VersionConflict,
},
}
impl From<String> for ProviderError {
fn from(message: String) -> Self {
ProviderError::Internal { message }
}
}