1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("Role '{0}' already exists")]
10 RoleAlreadyExists(String),
11
12 #[error("Role '{0}' not found")]
14 RoleNotFound(String),
15
16 #[error("Subject '{0}' not found")]
18 SubjectNotFound(String),
19
20 #[error("Permission denied: {0}")]
22 PermissionDenied(String),
23
24 #[error("Circular dependency detected in role hierarchy involving '{0}'")]
26 CircularDependency(String),
27
28 #[error("Invalid permission format: {0}")]
30 InvalidPermission(String),
31
32 #[error("Invalid resource format: {0}")]
34 InvalidResource(String),
35
36 #[error("Role elevation for subject '{0}' has expired")]
38 ElevationExpired(String),
39
40 #[error("Maximum role hierarchy depth exceeded (max: {0})")]
42 MaxDepthExceeded(usize),
43
44 #[cfg(feature = "persistence")]
46 #[error("Serialization error: {0}")]
47 Serialization(#[from] serde_json::Error),
48
49 #[error("Storage operation failed: {0}")]
51 Storage(String),
52
53 #[error("Invalid configuration: {0}")]
55 InvalidConfiguration(String),
56}
57
58pub type Result<T> = std::result::Result<T, Error>;