rust_rbac/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur in the RBAC system
4#[derive(Error, Debug)]
5pub enum RbacError {
6    #[error("Permission not found: {0}")]
7    PermissionNotFound(String),
8    
9    #[error("Role not found: {0}")]
10    RoleNotFound(String),
11    
12    #[error("Subject not found: {0}")]
13    SubjectNotFound(String),
14    
15    #[error("Storage error: {0}")]
16    StorageError(String),
17    
18    #[error("Permission already exists: {0}")]
19    PermissionAlreadyExists(String),
20    
21    #[error("Role already exists: {0}")]
22    RoleAlreadyExists(String),
23    
24    #[error("Invalid operation: {0}")]
25    InvalidOperation(String),
26    
27    #[error("Database error: {0}")]
28    DatabaseError(String),
29    
30    #[error("Unauthorized: Missing required permission {0}")]
31    MissingPermission(String),
32    
33    #[error("Unauthorized: Missing required role {0}")]
34    MissingRole(String),
35}