Skip to main content

systemprompt_users/
error.rs

1use systemprompt_identifiers::UserId;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum UserError {
6    #[error("User not found: {0}")]
7    NotFound(UserId),
8
9    #[error("User already exists with email: {0}")]
10    EmailAlreadyExists(String),
11
12    #[error("Invalid status: {0}")]
13    InvalidStatus(String),
14
15    #[error("Invalid role: {0}")]
16    InvalidRole(String),
17
18    #[error("Invalid roles: {0:?}")]
19    InvalidRoles(Vec<String>),
20
21    #[error("Database error: {0}")]
22    Database(#[from] sqlx::Error),
23
24    #[error("Validation error: {0}")]
25    Validation(String),
26}
27
28pub type Result<T> = std::result::Result<T, UserError>;