use thiserror::Error;

#[derive(Error, Debug)]
pub enum SqlError {
    #[error("Parse error: {0}")]
    ParseError(String),

    #[error("Table '{0}' not found")]
    TableNotFound(String),

    #[error("Table '{0}' already exists")]
    TableAlreadyExists(String),

    #[error("Column '{0}' not found in table '{1}'")]
    ColumnNotFound(String, String),

    #[error("Type mismatch: expected {expected:?}, got {actual:?}")]
    TypeMismatch {
        expected: String,
        actual: String,
    },

    #[error("Primary key violation: {0}")]
    PrimaryKeyViolation(String),

    #[error("Constraint violation: {0}")]
    ConstraintViolation(String),

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

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

    #[error("Invalid operation: {0}")]
    InvalidOperation(String),

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

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