Skip to main content

vr_core/
error.rs

1//! Error types for the VR platform.
2
3use crate::ids::TenantId;
4use crate::tenant::{Action, Resource, SubscriptionTier};
5
6/// Platform-wide error type.
7#[non_exhaustive]
8#[derive(Debug, nexcore_error::Error)]
9pub enum VrError {
10    #[error("tenant {tenant_id} not found")]
11    TenantNotFound { tenant_id: TenantId },
12
13    #[error("tenant {tenant_id} is not accessible (status: {status})")]
14    TenantInaccessible { tenant_id: TenantId, status: String },
15
16    #[error("permission denied: {action:?} on {resource:?} requires higher role")]
17    PermissionDenied { action: Action, resource: Resource },
18
19    #[error("tier {current:?} does not include this feature (requires {required:?})")]
20    TierInsufficient {
21        current: SubscriptionTier,
22        required: SubscriptionTier,
23    },
24
25    #[error("limit exceeded: {resource} — used {used}/{limit}")]
26    LimitExceeded {
27        resource: String,
28        used: u64,
29        limit: u64,
30    },
31
32    #[error("invalid input: {message}")]
33    InvalidInput { message: String },
34
35    #[error("not found: {entity} {id}")]
36    NotFound { entity: String, id: String },
37
38    #[error("conflict: {message}")]
39    Conflict { message: String },
40
41    #[error("internal error: {message}")]
42    Internal { message: String },
43}
44
45/// Convenience alias.
46pub type VrResult<T> = Result<T, VrError>;