1use crate::types::{RoleId, TenantId};
2use thiserror::Error;
3
4pub type StoreError = Box<dyn std::error::Error + Send + Sync>;
6
7pub type Result<T> = std::result::Result<T, Error>;
9
10#[derive(Debug, Error)]
12pub enum Error {
13 #[error("store error: {0}")]
15 Store(#[source] StoreError),
16 #[error("invalid id: {0}")]
18 InvalidId(String),
19 #[error("invalid permission: {0}")]
21 InvalidPermission(String),
22 #[error("role cycle detected for tenant {tenant} at role {role}")]
24 RoleCycleDetected { tenant: TenantId, role: RoleId },
25 #[error(
27 "role inheritance depth exceeded for tenant {tenant} at role {role}; max depth {max_depth}"
28 )]
29 RoleDepthExceeded {
30 tenant: TenantId,
31 role: RoleId,
32 max_depth: usize,
33 },
34}
35
36impl From<StoreError> for Error {
37 fn from(error: StoreError) -> Self {
38 Self::Store(error)
39 }
40}