use thiserror::Error;

#[derive(Debug, Error)]
pub enum LakehouseError {
    #[error("dataset not found: {0}")]
    DatasetNotFound(String),

    #[error("object not found: {bucket}/{key}")]
    ObjectNotFound { bucket: String, key: String },

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

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

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

    #[error("ai bridge error: {0}")]
    AiBridge(String),

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

impl LakehouseError {
    pub fn status_code(&self) -> u16 {
        match self {
            Self::DatasetNotFound(_) | Self::ObjectNotFound { .. } => 404,
            Self::Storage(_) | Self::Catalog(_) | Self::Query(_) | Self::AiBridge(_) => 500,
            Self::Serialization(_) => 400,
        }
    }
}
