gbserver/gb-auth/src/errors.rs
2024-12-24 13:05:54 -03:00

24 lines
No EOL
594 B
Rust

use gb_core::Error as CoreError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AuthError {
#[error("Invalid token")]
InvalidToken,
#[error("Invalid credentials")]
InvalidCredentials,
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
#[error("Redis error: {0}")]
Redis(#[from] redis::RedisError),
#[error("Internal error: {0}")]
Internal(String),
}
impl From<CoreError> for AuthError {
fn from(err: CoreError) -> Self {
match err {
CoreError { .. } => AuthError::Internal(err.to_string()),
}
}
}