Skip to main content

powdb_auth/
error.rs

1/// Structured error type for the auth crate.
2///
3/// Mirrors the `thiserror`-based style used by `powdb-storage`. Kept
4/// intentionally small — this slice is a library + data model only.
5#[derive(Debug, thiserror::Error)]
6pub enum AuthError {
7    /// Password hashing failed (argon2 internal error).
8    #[error("password hashing failed: {0}")]
9    Hash(String),
10
11    /// A user with the given name already exists.
12    #[error("user already exists: {0}")]
13    UserExists(String),
14
15    /// No user with the given name is known.
16    #[error("unknown user: {0}")]
17    UnknownUser(String),
18
19    /// The referenced role is not a known builtin.
20    #[error("unknown role: {0}")]
21    UnknownRole(String),
22}
23
24/// Convenience alias used throughout the auth crate.
25pub type Result<T> = std::result::Result<T, AuthError>;