use thiserror::Error;

#[derive(Error, Debug)]
pub enum RoomError {
    #[error("Database error: {0}")]
    Database(#[from] sea_orm::DbErr),

    #[error("Not found: {0}")]
    NotFound(String),

    #[error("Unauthorized")]
    Unauthorized,

    #[error("No power / permission denied")]
    NoPower,

    #[error("Rate limited: {0}")]
    RateLimited(String),

    #[error("Bad request: {0}")]
    BadRequest(String),

    #[error("Role parse error")]
    RoleParseError,

    #[error("Internal error: {0}")]
    Internal(String),
}

impl From<anyhow::Error> for RoomError {
    fn from(e: anyhow::Error) -> Self {
        RoomError::Internal(e.to_string())
    }
}

impl From<agent::error::AgentError> for RoomError {
    fn from(e: agent::error::AgentError) -> Self {
        RoomError::Internal(e.to_string())
    }
}
