use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Redis error: {0}")]
Redis(#[from] redis::RedisError),
#[error("Config error: {0}")]
Config(String),
#[error("Agent not found: {0}")]
AgentNotFound(String),
#[error("Task not found: {0}")]
TaskNotFound(String),
#[error("Agent already exists: {0}")]
AgentExists(String),
#[error("Failed to assign task: {0}")]
AssignmentFailed(String),
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Town not initialized at {0}. Run 'tt init' first.")]
NotInitialized(String),
#[error("Redis not running. Start with 'tt start' or ensure Redis is available.")]
RedisNotRunning,
#[error(
"Redis not found. Run 'tt bootstrap' to download and build Redis automatically.\n\nAlternatives:\n - macOS: brew install redis\n - Ubuntu: sudo apt install redis-server\n - Manual: https://redis.io/downloads/"
)]
RedisNotInstalled,
#[error(
"Redis version {0} is too old. Tinytown requires Redis 8.0+.\n\nRun 'tt bootstrap' to install the latest version.\n\nAlternatives:\n - macOS: brew upgrade redis\n - Ubuntu: See https://redis.io/downloads/"
)]
RedisVersionTooOld(String),
#[error("Operation timed out: {0}")]
Timeout(String),
#[error("Migration error: {0}")]
Migration(String),
}
pub type Result<T> = std::result::Result<T, Error>;