123 lines
3.3 KiB
Rust
123 lines
3.3 KiB
Rust
//! Error types for the RustyTorch++ Platform
|
|
|
|
pub type PlatformResult<T> = Result<T, PlatformError>;
|
|
|
|
/// Platform error types
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum PlatformError {
|
|
#[error("Region error: {0}")]
|
|
Region(#[from] RegionError),
|
|
|
|
#[error("Tenant error: {0}")]
|
|
Tenant(#[from] TenantError),
|
|
|
|
#[error("Billing error: {0}")]
|
|
Billing(#[from] BillingError),
|
|
|
|
#[error("Federation error: {0}")]
|
|
Federation(#[from] FederationError),
|
|
|
|
#[error("SLO error: {0}")]
|
|
Slo(#[from] SloError),
|
|
|
|
#[error("Database error: {0}")]
|
|
Database(#[from] sqlx::Error),
|
|
|
|
#[error("Redis error: {0}")]
|
|
Redis(#[from] redis::RedisError),
|
|
|
|
#[error("Network error: {0}")]
|
|
Network(#[from] reqwest::Error),
|
|
|
|
#[error("Configuration error: {message}")]
|
|
Config { message: String },
|
|
|
|
#[error("Security error: {message}")]
|
|
Security { message: String },
|
|
|
|
#[error("Resource exhausted: {resource}")]
|
|
ResourceExhausted { resource: String },
|
|
|
|
#[error("Internal error: {message}")]
|
|
Internal { message: String },
|
|
|
|
#[error("Validation error: {message}")]
|
|
Validation { message: String },
|
|
|
|
#[error("Authorization error: {message}")]
|
|
Authorization { message: String },
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum RegionError {
|
|
#[error("Region not found: {region_id}")]
|
|
NotFound { region_id: String },
|
|
|
|
#[error("Region unavailable: {region_id}")]
|
|
Unavailable { region_id: String },
|
|
|
|
#[error("Region capacity exhausted: {region_id}")]
|
|
CapacityExhausted { region_id: String },
|
|
|
|
#[error("Cross-region communication failed: {src} -> {dst}")]
|
|
CrossRegionFailed { src: String, dst: String },
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum TenantError {
|
|
#[error("Tenant not found: {tenant_id}")]
|
|
NotFound { tenant_id: uuid::Uuid },
|
|
|
|
#[error("Tenant quota exceeded: {tenant_id}, resource: {resource}")]
|
|
QuotaExceeded {
|
|
tenant_id: uuid::Uuid,
|
|
resource: String,
|
|
},
|
|
|
|
#[error("Tenant isolation violation: {tenant_id}")]
|
|
IsolationViolation { tenant_id: uuid::Uuid },
|
|
|
|
#[error("Authentication failed for tenant: {tenant_id}")]
|
|
AuthFailed { tenant_id: uuid::Uuid },
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum BillingError {
|
|
#[error("Usage tracking failed for tenant: {tenant_id}")]
|
|
UsageTrackingFailed { tenant_id: uuid::Uuid },
|
|
|
|
#[error("Billing calculation failed for tenant: {tenant_id}")]
|
|
CalculationFailed { tenant_id: uuid::Uuid },
|
|
|
|
#[error("Payment processing failed for tenant: {tenant_id}")]
|
|
PaymentFailed { tenant_id: uuid::Uuid },
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum FederationError {
|
|
#[error("Federation policy violation: {policy}")]
|
|
PolicyViolation { policy: String },
|
|
|
|
#[error("Privacy constraint violation: {constraint}")]
|
|
PrivacyViolation { constraint: String },
|
|
|
|
#[error("Cross-federation communication failed")]
|
|
CommunicationFailed,
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum SloError {
|
|
#[error("SLA violation: {metric} = {value}, threshold = {threshold}")]
|
|
SlaViolation {
|
|
metric: String,
|
|
value: f64,
|
|
threshold: f64,
|
|
},
|
|
|
|
#[error("Monitoring failure: {component}")]
|
|
MonitoringFailure { component: String },
|
|
|
|
#[error("Alert delivery failed: {alert_type}")]
|
|
AlertDeliveryFailed { alert_type: String },
|
|
}
|