use thiserror::Error;

#[derive(Error, Debug)]
pub enum ClosureError {
    #[error("authentication required — run `closure auth`")]
    AuthRequired,

    #[error("invalid password")]
    InvalidPassword,

    #[error("provider not found: {0}")]
    ProviderNotFound(String),

    #[error("provider already exists: {0}")]
    ProviderAlreadyExists(String),

    #[error("agent config not found: {0}")]
    AgentConfigNotFound(String),

    #[error("io error: {0}")]
    Io(#[from] std::io::Error),

    #[error("json error: {0}")]
    Json(#[from] serde_json::Error),

    #[error("toml error: {0}")]
    Toml(#[from] toml::de::Error),

    #[error("toml serialize error: {0}")]
    TomlSerialize(#[from] toml::ser::Error),

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

    #[error("sync conflict: {0}")]
    SyncConflict(String),
}

pub type Result<T> = std::result::Result<T, ClosureError>;
