use thiserror::Error;
#[derive(Debug, Error)]
pub enum AuthzError {
#[error("Policy parse error: {0}")]
PolicyParse(String),
#[error("Schema parse error: {0}")]
SchemaParse(String),
#[error("Policy validation error: {0}")]
PolicyValidation(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Internal authorization error: {0}")]
Internal(String),
}
pub type Result<T> = std::result::Result<T, AuthzError>;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn error_display() {
let e = AuthzError::PolicyParse("bad syntax".into());
assert!(e.to_string().contains("bad syntax"));
}
}