systemprompt_users/
error.rs1use systemprompt_identifiers::UserId;
7use systemprompt_models::domain_error;
8
9domain_error! {
10 pub enum UserError {
11 common: [repository, validation],
12
13 #[error("user not found: {0}")]
14 NotFound(UserId),
15
16 #[error("user already exists with email: {0}")]
17 EmailAlreadyExists(String),
18
19 #[error("invalid status: {0}")]
20 InvalidStatus(String),
21
22 #[error("invalid role: {0}")]
23 InvalidRole(String),
24
25 #[error("invalid roles: {0:?}")]
26 InvalidRoles(Vec<String>),
27
28 #[error("pool error: {0}")]
29 Pool(String),
30 }
31}
32
33impl From<sqlx::Error> for UserError {
34 fn from(err: sqlx::Error) -> Self {
35 Self::Repository(systemprompt_database::RepositoryError::from(err))
36 }
37}
38
39pub type Result<T> = std::result::Result<T, UserError>;
40
41pub type UserResult<T> = Result<T>;