use thiserror::Error;

#[derive(Debug, Error)]
pub enum QueryError {
    #[error("query validation failed: {0}")]
    ValidationErrors(validator::ValidationErrors),
    #[error("sqlx error: {0}")]
    SqlxError(sqlx::Error),
}

impl From<validator::ValidationErrors> for QueryError {
    fn from(value: validator::ValidationErrors) -> Self {
        Self::ValidationErrors(value)
    }
}

impl From<sqlx::Error> for QueryError {
    fn from(value: sqlx::Error) -> Self {
        Self::SqlxError(value)
    }
}
