Skip to main content

chronix_security/authz/
error.rs

1//! Error types for the Chronix authorization system.
2
3use thiserror::Error;
4
5/// Errors that can occur during authorization operations.
6#[derive(Debug, Error)]
7pub enum AuthzError {
8    /// A policy failed to parse.
9    #[error("Policy parse error: {0}")]
10    PolicyParse(String),
11    /// A Cedar schema failed to parse.
12    #[error("Schema parse error: {0}")]
13    SchemaParse(String),
14    /// Policy validation against schema failed.
15    #[error("Policy validation error: {0}")]
16    PolicyValidation(String),
17    /// An I/O error occurred loading policies.
18    #[error("I/O error: {0}")]
19    Io(#[from] std::io::Error),
20    /// An internal error.
21    #[error("Internal authorization error: {0}")]
22    Internal(String),
23}
24
25/// Result type alias for authorization operations.
26pub type Result<T> = std::result::Result<T, AuthzError>;
27
28#[cfg(test)]
29mod tests {
30    use super::*;
31
32    #[test]
33    fn error_display() {
34        let e = AuthzError::PolicyParse("bad syntax".into());
35        assert!(e.to_string().contains("bad syntax"));
36    }
37}