2022-04-18 12:13:15 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2022-06-23 09:52:48 +00:00
|
|
|
use thiserror::Error;
|
2022-04-18 12:13:15 +00:00
|
|
|
|
2022-06-23 09:52:48 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, Error)]
|
2022-04-18 12:13:15 +00:00
|
|
|
pub enum Error {
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Username or Password incorrect.
|
2022-04-18 12:13:15 +00:00
|
|
|
#[error("user not found")]
|
|
|
|
UserNotFound,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Cannot create a user because username already exists.
|
2022-04-18 12:13:15 +00:00
|
|
|
#[error("user already exists")]
|
|
|
|
UserAlreadyExists,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Username is too short.
|
2022-04-30 19:56:06 +00:00
|
|
|
#[error("username is too short")]
|
|
|
|
UsernameTooShort,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Username is too long.
|
2022-04-30 19:56:06 +00:00
|
|
|
#[error("username is too long")]
|
|
|
|
UsernameTooLong,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Password is too short.
|
2022-04-30 19:56:06 +00:00
|
|
|
#[error("password is too short")]
|
|
|
|
PasswordTooShort,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Failed to generate user token.
|
2022-04-21 18:54:53 +00:00
|
|
|
#[error("generate jwt token")]
|
|
|
|
TokenGenerate,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Incorrect user token.
|
2022-04-23 21:48:20 +00:00
|
|
|
#[error("invalid jwt token")]
|
|
|
|
InvalidToken,
|
2022-06-11 08:19:47 +00:00
|
|
|
/// Other error.
|
|
|
|
#[error("other error - {0}")]
|
|
|
|
Other(String),
|
2022-04-18 12:13:15 +00:00
|
|
|
}
|