llldap/src/db/error.rs

22 lines
588 B
Rust
Raw Normal View History

2026-09-01 19:06:33 +02:00
use std::fmt;
use crate::db::UserRef;
2026-09-01 23:27:02 +02:00
pub type BoxedError = Box<dyn std::error::Error + Send + Sync + 'static>;
2026-09-01 19:06:33 +02:00
#[derive(Debug)]
pub enum UserCreationError {
UserAlreadyExists(UserRef),
Permissions,
}
2026-09-01 19:06:33 +02:00
impl fmt::Display for UserCreationError {
2026-09-01 19:06:33 +02:00
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UserAlreadyExists(user) => write!(f, "User already exists: {user}"),
Self::Permissions => write!(f, "You do not have permissions to create this user"),
}
2026-09-01 19:06:33 +02:00
}
}
impl std::error::Error for UserCreationError {}