HomeDisk/types/src/errors/auth.rs

31 lines
863 B
Rust
Raw Normal View History

use serde::{Deserialize, Serialize};
2022-06-23 09:52:48 +00:00
use thiserror::Error;
2022-06-23 09:52:48 +00:00
#[derive(Debug, Clone, Serialize, Deserialize, Error)]
pub enum Error {
2022-06-11 08:19:47 +00:00
/// Username or Password incorrect.
#[error("user not found")]
UserNotFound,
2022-06-11 08:19:47 +00:00
/// Cannot create a user because username already exists.
#[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.
#[error("generate jwt token")]
TokenGenerate,
2022-06-11 08:19:47 +00:00
/// Incorrect user token.
#[error("invalid jwt token")]
InvalidToken,
2022-06-11 08:19:47 +00:00
/// Other error.
#[error("other error - {0}")]
Other(String),
}