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)]
|
2026-09-04 18:35:46 +02:00
|
|
|
pub enum UserCreationError {
|
|
|
|
|
UserAlreadyExists(UserRef),
|
|
|
|
|
Permissions,
|
|
|
|
|
}
|
2026-09-01 19:06:33 +02:00
|
|
|
|
2026-09-04 18:35:46 +02:00
|
|
|
impl fmt::Display for UserCreationError {
|
2026-09-01 19:06:33 +02:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
2026-09-04 18:35:46 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-04 18:35:46 +02:00
|
|
|
impl std::error::Error for UserCreationError {}
|